 Hello, I'm Denshi and in today's video I'm going to be showing you how to use FFmpeg with some basic examples. So I'll just get rid of a bunch of files here real quick. And just pretend I only have one file here, outro.mp4, and if I double click on this and I play it back, you'll notice it's just the outro from all my videos. And yeah, that's what I use as my outro, let's say I want to convert it to an MKV for example. Well, I have a program named FFmpeg and if you're running GNU Linux and you have a desktop environment installed, this is already on your system, including all the codecs that you're going to need to do all the convergence. So let's say I want to convert this file. So I'm going to do ffmpeg-i outro, so dash i means input, and if I don't give it any other parameters and just press enter, it will give me information on the file. So as you can see here, it tells me that stream 0 0, it's using the HEVC encoder which is a modern functional encoder, U420p like pixel format, it's at 1920x1080 in terms of resolution, it's at 60fps and all of this stuff. For audio, it's using AAC, it's a 48000 Hz sample rate, stereo and 128 kilobytes per second as the bit rate, so yeah, all of that stuff. Now let's say I want to convert it to an MKV. Without any parameters, ffmpeg defaults to a bunch of stuff that it has pre-built in it, I can just tell it to convert it to outro.mkv. So it might take a little bit of time because this is a 20 second long video, but eventually after I've done running this command, so outro.mp4, outro.mkv, just specifying I want it to go from this is my input to just this output, I get an output and if I double click and play this, you'll see it's pretty much the same thing. Now what if I want to specify different encoders? So this used h264 as the encoder because by default ffmpeg will try to use h264 when converting things to MKV. Let's say I want to use h265 or HEVC, I can do dash cv and specify libx265 as my video codec, same for audio. If I want to use AAC for example which is higher quality, lossless audio, I can do dash c, aac. I can give them more options. So for example, I want to scale the video, I can do dash s and like 1280x720, that's 720p. Let's say I want to give it a rate, I'll keep this for now. In the meantime, before I talk about more options, I'm going to quickly run this and cancel it so I have it saved. I'm going to talk about how to actually get the encoder list. You saw me write out libx265, how do I know what all the encoders are? Well if you want to see all the encoders, you do ffmpeg dash encoders and that will print them all out. If I want all of those to go to like a file, just do ffmpeg dash encoders and send them over to like, I don't know, encoders.txt. So there you go and it will create encoders at txt, you can look through these and there's all the encoders you can possibly use on a system. Now not all of these might work with your system, maybe you don't have the hard drive for some of these or your processor is too old or maybe they're just not supporting enough that certain things downloaded or something like that, but most of these should work. And the reason all of these are here is because video comes in many variations. So the one I use was, let's see if I can spot it, here we are, libx265, so this is h265, also known as HEVC, h264, this is the NVIDIA version, but up here we got h264 VAAPI, so that's the version for video accelerated stuff, and then somewhere up there, here we are, you'll find libx264, so that's h264, that's the actual, you know, standard codec. Anyway, but this isn't what's important now, let's go back to where we were before I think I need to go, wait a second, you know, open up the main toolbar, not main, sorry, settings, show, tabs, go back to the previous file I was in, this one. Anyway, so back to what I was talking about before, let's say I want to take, I don't know, let's just delete this file, let's say I want to take outro.mp4 and convert it with what I was doing before, this, I want to use aac as my audio codec, x265 as my video codec, basically the best ones out there pretty much, and I want the resolution to be 720p, let's say I want to change the audio rate, so colon A and I give it something like 44100, a common audio rate, just give it a couple of spaces so things are a little bit more evenly formatted here, spaces don't matter, let's say I want to change the video bitrate, dash B, the one megabyte, at most it can reach one megabyte per second, most likely won't, but if I really want to, or let's say I want the audio bitrate to be something I can do, dash B, A and bitrate audio instead of 292 kilobytes per second, or kilobytes per second, now setting video bit rates is pretty pointless when you're using something like x265 or h264, all that stuff because there's already an inbuilt utility for it, it's called dash CRF and it's much better, it's varying the bit rate based off a number you give it, so the lower the number is, the better the quality will be but the bigger the file is, so let's say I want it to be 24, 24 is a good number, most of my videos are 20, I set the CRF rate to 24 when I compressed them, including this one, it's 24, and as you can see it looks pretty good, if you need higher quality, 20, but it's pretty indistinguishable, a little bit maybe with more noisy video, but for most video it's perfectly fine, anyway moving on, let's say I want to change the duration as well as this video, I can do dash SS to declare when I wanted to start, I wanted to start at, well, zero hours, zero minutes, zero seconds, and zero milliseconds, and let's say I wanted to end so dash T at zero hours, zero minutes, and zero five seconds, and zero milliseconds, I can also, that's pretty much it, no, so I'm gonna do outside MP4, I'm gonna use x265, I'm gonna set my codec to AAC for audio, I'm going to scale it down to 720p, change the audio bit rate to 44100, I use CRF 24, so you know pretty good quality for H265 and stuff, set my bit rate of audio to 192 kilobytes per second, start the video at zero zero, just the beginning of the video, and end it at five seconds, so let's press enter and let it work, since it only had to do five seconds, it was relatively quick, and if you play this back, as you can see it lasts five seconds, it's in 720p, and everything's been applied, so ffmpeg is a really powerful tool when you want to mass convert files because you can just write a script and and mass convert every single mp4 file to a different format or every single mp4 file, compress it or something else or or something like that, and let's say I want to take this outro.mp4 file and turn it into audio, well that's the same concept, dash I, outro.mp4, if I want to specify a specific audio codec, I don't know, libopus or something, but I'm just gonna say outro.wav, let's just turn it into wav, instantly done, there you go, outro.wav, double click that, and as you can see it plays back because I've converted it to audio, and here right before I end this video, because I've talked about all the main options, let's do a fun little experiment, let's transform this outro.wav and this image into a video, so I'm going to take outro.wav and essentially mix it with this image, so I'm going to do ffmpeg dash I, outro.wav, and then dash I, image.png, and I'm going to specify a specific codec, so let's say I want libx265, relatively good, the crf, I don't know, 2020 is pretty good in terms of quality, images are a little bit messed up when it comes to this kind of stuff, and let's say I want something like audio codecs, okay, I might want to specify a bitrate for audio though, so I'm going to do ba and set it to 192 kHz, so let's press enter on this, and oh yeah, I forgot to set an output file, so wait a second, I'm going to specify I want it to be outro.image.mp4, press enter and just let it convert, there you go, it's already done, double click on this, and as you can see it's the image with the audio, it's just the image playing back and it has the audio from outro.wav, which is just the raw 20 second audio, and it mixes it with this image, so if you ever wanted to just have a still image and you're talking, you can make that pretty easily in the file itself, it's negligible in terms of size, so it's minus good, it's 489 kilobytes, so if you ever need to make a video where it's just like an image, and that's all, you can do that pretty easily with this. So anyway, thanks for watching my video on how to use ffmpeg with some basic options, I'll have all a bunch of examples in the description if you want to take a look at them, I'll just have this entire thing in the description actually, and yeah ffmpeg is a really useful tool, I recommend if you're into video stuff, you learn how to use it, the best encoders for video are at the moment libx265, the best encoder for audio is AAC because high quality, x265 is, you know, as long as you set your CRF rate appropriately, it's going to be perfectly fine in terms of quality, might be a little slow because processors and stuff, if you need to deal with something like Nvidia encoding, you can do obviously what was it called, nvenc underscore HEVC, that's another codec you can use, but it's actually, I think it's HEVC underscore nvenc, and it's fast, but it isn't as precise because GPUs aren't like perfect processors when it comes to video, and the file size will be larger and it won't be as high quality video, but yeah, that's pretty much it, thanks for watching my video, goodbye.