 Hey, what's up everyone? This video is going to be on how to make your own videos in Linux just sort of automatically in the command line so you can put them on YouTube, you can do screencasts, or you can just use them for whatever you want to use them. So this is actually going to be the first on a series of videos I'm going to do on FFmpeg, which is one of the most useful utilities out there. Of course the documentation calls it a video converter. It does do that. It also does great recording. You can splice videos. You can do every little thing you need to do. You might use a huge video editor to do all this complex stuff where really FFmpeg can just do it with one command. So in this video we're going to talk about how to do screencasts, how to do recordings, and stuff like that. So the syntax of FFmpeg is actually super simple. The principle is really you have an itag and that means input. You give it some kind of input file then you give it an output file and it's just going to take that and put it in that. Now your input file, it could be a literal file. It could also be your webcam or it could be your screen here. So effectively what it's going to do is it's just going to like take your screen and put it in a file or something like that. So it's a great all purpose tool and there's a whole lot of details to it but let's go ahead and get into the basics of actually screencasting with it. So FFmpeg in addition to having these input tags, they have an F tag and this really means a format because not everything is a file, some things are a little different. So if you want to record our screen, what we do is put in the F tag and then F11 grab. So this is going to take your X server, whatever is appearing on your screen and it's going to take that as the kind of file we're looking for. And then the input file we're actually going to put in is just going to be this, 0.0 and this just means the default screen which is I only have one screen. You might only have one screen probably and that's pretty much all you need. So what we're saying here is just FFmpeg take our default X screen. Now we're going to put it into an output. So I'm going to say out.inkv. So this is just going to go right where we are now. So now what it's doing is it's just recording what's appearing on my screen and it's putting it straight in that file. But of course it's a little more complicated than that. So here's our file here, here right here is actually the video I'm recording that you're watching now. But we'll open up out, see what it looks like. So we are successfully screencasting, as you can see. But it's only screencasting a portion of the actual screen. We want more than that. So I'm going to Ctrl C to cancel this. That's an acceptable way to cancel it, I say. So what we want to do is add in a screen size as well because we don't just want this portion up here, we don't want the whole thing. So to do that you use the S tag. So I'm going to go ahead and put in my screen size, which I think is 1680 by 1050, I think. So you know, just typical format here. Now the important thing that one important thing to realize is you should put the screen size before the input. There are some like linear order sensitive arguments of ffmpeg. If you put the screen size after the input, it's going to just take this little sliver of the input, but it's going to make it big. We don't want to do that. We want to record the whole screen. So now I'm going to do this again, I'm going to run this command again. It's going to ask me if I want to overwrite. I'm going to say yes. Because we already have a file of that name. And I'm going to let it record for a couple seconds. Just to make sure it works. And we can open it up in a second. Oh, look at that. Let me actually stop the recording. We have our first full screen ffmpeg recording looks just like the actual screen here, but whatever. So that's pretty nice. Now now you sort of have half of the puzzle. We now have good video recording. But just so you know, there are other possibilities. So this is x11 grab. You can grab from other things. Let's say you want to record from your webcam, you want to do a video of you. That's super. That's actually probably even easier. So in Linux, Linux actually stores in case you don't know its devices and dev and webcams are usually stored as like video zero, video one, whatever. If you just have one webcam, it's probably going to be video zero. So you can just take the input file as dev video zero. And we'll give it another output, you know, the same output file. Oh, if you want to automatically overwrite this file, it's going to ask me otherwise, you can just put tag y in there. So I'm going to start recording this, I will say I don't actually have a webcam. I have a USB microscope. But well, it'll record just the same. So now I'm waving my hand in front of it so you can see it, but it's just going to be blurry because it's supposed to be super small resolution. But so now I'm recording from this webcam. I'm going to go ahead and cancel it and we can look at it. And that's what we've recorded. That's how it's supposed to look. Again, it's a microscope recording, but you can record from yours and get you know, your full face and I'm sure you'll look beautiful. Okay, so that is recording video. So let's actually go back to the command we had a second ago, the x 11 grab command, and I'm going to throw in the y tag. Again, that's the automatically overwrite that the output. So let's say we want to record audio. So audio keep in mind that Linux distributions usually have two different ways of doing audio. They use pretty much all of them have also, which is like the sort of default, you know, Linux sound server thing. But a lot of them, including the ones I use, well, most of them I'll say that also use pulse audio. So I actually have a couple scripts for both audio, also and pulse audio. So they record audio, the syntax of how you record audio from them is going to be a little different in both situations. So if you want to record from pulse audio, these are the scripts that I use to record my stuff, by the way. If you want to record from pulse audio, how I do it is I force it to take an ulcer input, which is a little ironic, but it's acting on pulse audio. And then you give it default as the input. And what this is going to you basically use pulse audio to look at the ulcer inputs, it's going to look specifically at the default one. Okay, so we can go ahead and start recording this. And so now it's bait, I'm doing, now I'm doing a screen cast and a screen cast. So, oh, and one additional note, if you're using pulse audio, you're going to want to open a PAHVU control, which you probably should have installed, but PAHVU control is just this control center for managing pulse audio. You're going to want to go to the recording tag and make sure that the default recorder is actually the thing you want, because when the script is looking for the default, it's looking for whatever is set here. And by default, it might actually be something you don't want to record from, like your crappy laptop microphone when you actually want to record from your USB microphone. So once you go here and set it, you should have the recording running when you do it. But once you set it for all like sequential recordings, every time you record again, it's actually going to automatically record from the thing you want. Okay, so now we have audio in the recording. I had to stop the video because it wasn't turning on. It ends up I just didn't have a long enough recording. One thing, due to the way that FFNPEG records, sometimes it sort of, you know, puts the video in the file in spurts. So if you have a really short recording, sometimes it won't actually write to the file. So just be aware of that. That happens. But I do now have an audio recording, which you may or may not be able to hear. But that's pretty much it. So that's how you get audio recording in Pulse Audio. Now if you want to do also, I'll have my script for that in the video description. But most distributions don't use also alone. So you're probably going to want to go with this one. So the other thing to note is that we have just been recording without specifying codecs. Some people might not recommend that. I think it's okay, you know, for most uses. But just know that in addition, let's actually maximize this, in addition to just specifying the inputs, you can also specify codecs. So if you give it this option, like C colon V, you can then specify a codec for the video. So this is just codec video. And C colon A is just codec for the audio. So normally when I record stuff, I use libx264 as a video codec and FLAC as an audio codec. I think by default it records in libvorbis and impact or for something. I'm not entirely sure. Okay, but anyway, that's the gist of it. So now what we've done, we have a little script here that on this machine with this particular resolution, it's going to record video and audio. Now we can make additional changes to that. In fact, actually let me bring up that script I just had up. So one thing, one problem that I often have is that I sometimes do screen casts on my laptop. Sometimes I have my laptop plugged up to the screen, which is a little bigger. So on different machines, I'm going to have a different resolution. So usually what you want to do is instead of like using a script like this that you just run manually, you're going to want to have like a more dynamic script that can automatically call your, the actual dimensions of your machine. So that's what I have here. So this xdpi info, this just gives you info about you know your xserver. And you can grep out dimensions. That's what I do here. And then you use awk to just select the second thing here. So this is a script. If you replace s with this thing here, what that's going to do is it's going to automatically get your screen resolution. So you don't have to actually worry about that. Now aside from that, this is pretty much all you need for doing actual screencasts. So you can now record both video and audio if you want. I'll also say if you don't want to actually, let's say you don't have a microphone, you know, you want to start your YouTube channel, you don't have a microphone, but you can do everything in video. Additionally, instead of having this also input, you can just put another eye and let's say you just have a music file. So like music, music dot flack or something like that, you can take that as an input file and it'll just throw that in the recording when it actually records. So that's another viable option if you're just trying to, you know, if you're trying to produce content. And of course, you don't actually have to include, you know, ffmpeg in theory is a video, you know, software system, but you don't actually have to record any video whatsoever. You can just use it to record your audio. That's what I do when I only need to record my audio stuff. I have a script, you know, something like that. Let's give it to that if, you know, I have a script only recording from also or something like that. And that's going to be it. So anyway, this is just a super basic intro to the kind of stuff you can do to screencast with ffmpeg. I guess my goal has been to sort of give you an idea of how it works, not necessarily just throw commands at you. But I'm probably going to do the next video on the series is going to be about how to splice videos, how to merge them, how to cut parts out, because there's really no sense in opening a huge video editor when you could just do everything in the command line. So anyway, that's going to be the next video. Hope you enjoyed it. Hope it is useful to you. And I look forward to seeing all the great content that you're going to put out because you can do that. So anyway, see you next time.