How to Record Video in Linux With ffmpeg

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up everyone today we're going to take a look at screen recording in linux now there's a couple of ways that you can go about doing this um one way that i used to do a lot and probably the method that you've heard of is by using obs and obs is probably the most straightforward way to do screen recordings not just in linux but on windows it's a cross-platform application but there are a couple of problems with the obs approach first of all it's a little bit bloated now it's not the worst case of bloat which would be bloat just for the sake of bloat but it's a bit bloated because it does a lot of stuff that maybe you don't actually need to use like if we just take a look at this interface you can see that there's a lot going on in this application so you have an audio mixer down here where you can see the levels of like your microphone and other audio sources in real time you can adjust them in real time you can um go into your filters and you can apply um like gain expander limiters things like that and i think this actually works with vst plug-ins so you can get really fancy if you start getting into that world there's your different sources so like you can have video from different monitors and there's a lot going on in here and it's probably quite a bit more than you would need if you're someone like me who just needs to record one screen uh get output from one microphone and then maybe also get output from the desktop audio as well so that's one reason to consider something else and another reason is uh obs really does not play nice with a pure elsa setup and i'm actually doing an experiment right now in gen 2 to see how viable it actually is to live in pure elsa so no jack no pulse audio which for probably 99 of linux users out there that's what that is actually handling their audio well technically everybody has elsa but pulse audio is just this thing that's built on top of it that most people are using and in a lot of cases it's not actually necessary um like i can consume content without pulse audio that's really easy recording is is a little bit more complicated but anyway that'll be a different video if the experiment's successful if you try to run a pure elsa setup and you go into obs and right now i do have pulse audio installed full disclosure but if i didn't and i went under audio devices this whole area here would be blank it wouldn't even say disabled it would literally just be a you know blanked out input field and you wouldn't actually be able to click this to select your inputs this whole section would just be broken now luckily you can add elsa audio sources to obs um but they don't like to work a lot of the time the only one that just worked was my yeti mic which makes sense because this is like the most common microphone that every youtuber under the sun uses um but yeah like my my uh duo capture to collect or to capture desktop audio that wasn't working there was a lot of configuration i had to do in elsa to actually get it working so but the point is obs is not a viable option if you want to go pure elsa which brings me to ffmpeg now this is an application that you've uh probably that you probably already have honestly on your linux box because it's necessary it's a dependency for pretty much any application that has anything to do with video certainly video recording or video editors it is officially a video converter as you can see from the top of the man page here but it is able to do so much more than just converting different video formats so let's get into it the simplest way to use ffmpeg is with the i switch so you would specify an input file and then an output file and this can be a file in the traditional sense like it can be a wave an mp4 and then same thing with your output this can be like an mkv or an mp4 but you might know that in linux everything is treated as a file everything is technically a file so your webcam that's connected to your computer that is a file your microphone that is connected that is a file and your screen as well is a file now the syntax for specifying the screen is a little bit more complicated you have to use the f switch to specify the format and it's going to be x11 grab which as the name implies it just grabs your x11 instance and then turns it into a file and then we're going to use i for our input and then we're going to put in our monitor which is 0.0 now this is what your monitor is if you've got a single monitor so you know you're basically done you can do dot mkv and then that's going to start uh casting your monitor into this file here but as you saw i have multiple monitors so there's a bit more work that we have to do i know first world problems uh so this is my x randar output and you'll notice that as it lists all my monitors here there's uh the listing of the monitor the current resolution and then there's coordinates that specify where that monitor is so this one hdmi zero is actually my middle monitor that you're looking at now this is at 1920 plus zero this one here the display port that's the monitor to my right this is at zero uh zero zero and then dvid is to my left that's at 38.40 so if i just want to record my middle monitor like i would in pretty much all of my recordings i got to specify those coordinates so we'll come back over to this and we're going to add here plus 1920 comma zero uh and there's one other thing that we have to do when we're specifying a monitor but really this is just um this is just good practice in general like you should do this even if you're just recording a single monitor is specify the size so that's going to be 1920 by 1080 and the reason for that is if you don't specify the size of the screen that you're recording then it can get cut off like it might um it might uh just do like half of it or whatever um and then this file out mkv already exists so yeah we'll just go ahead and overwrite it and so now you can see it is recording um oh and you might be wondering what would happen if you have multiple monitors and you didn't specify that coordinate what uh ffmpeg is actually to do is it's going to record all of your screens at once and if you've got three like i do it's going to look ridiculous because the um the resolution is going to be like uh whatever times three is like five actually i think it says it over here yeah so your resolution is going to be this right here five 760 by 1080 which is going to look really stupid unless somebody's watching it on some like ultra super mega widescreen monitor so i think we can cancel this now and you can just do control c to cancel it and you'll see that now i have this out dot mkv and i can play it and so you see this is the screen that was being recorded um we can actually move this to another another tag and get full screen so you can see that it's good quality it's not a shoddy application or anything it records just as good as obs or anything else does so we'll quit out of that now now a screencast wouldn't be a screencast without audio unless you're trying to do something like a youtube tutorial circa 2008 where you just type things out in notepad and you know you put some annoying music over it and then you record it with an unregistered hypercam but in ffmpeg to specify an audio device let's bring up that original command that i had there you want to specify an elsa device so if we come after where we have the screen resolution there we can then do f elsa i and then we need to figure out what our elsa device actually is so if we come back here you can do a record l and this is going to list out all your different devices here so for example the yeti microphone this is card three and i bet you this isn't actually gonna work because my yeti microphone is in use and i don't have the uh elsa patch to be able to record from multiple things but i can just do the example um so we do i hardware or hw colon and then the number that maps to whatever card you want to record and uh yeah of course it tells us device or resource busy but you know we can do like uh something different maybe we'll do the loopback because that's not doing anything right now and then yeah so you can see that this is going to record both video uh and audio at the same time and then it's automatically going to sync it up and again this can all be done in pure elsa if you only have one audio input then it actually isn't even that complicated to do the tough part that i've found in a pure else environment is trying to record your loopback audio which is just the sound that your desktop makes and your uh microphone at the same time like you would if uh maybe you were doing a let's play or you were covering something that's in the browser that requires you to play a video uh recording those at the same time is a little bit tough but like i said there's still some more experimenting that i'm willing to do to see how viable it is and if i can get it to work i'll be sure to give you guys a video of that as well but for now that was how to record in ffmpeg hope you guys enjoyed the video have a great one
Info
Channel: Mental Outlaw
Views: 39,553
Rating: undefined out of 5
Keywords: Mental Outlaw, mental, outlaw, ffmpeg, ffmeg linux, How to Record Video in Linux, record video linux, How to Record Video in Linux With ffmpeg, screencasting linux, screen recording, linux, gnu linux, computers, obs, tech, technology, video streaming linux, online streaming linux
Id: HO6oU5oT6uU
Channel Id: undefined
Length: 11min 46sec (706 seconds)
Published: Fri Dec 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.