[0:00] hello i'm denchi and in today's video [0:02] i'm going to be showing you how to use [0:04] ffmpeg with some basic examples so i'll [0:06] just get rid of a bunch of files here [0:08] real quick [0:09] and just pretend i only have one file [0:11] here outro.mp4 now if i double click on [0:14] this and i play it back [0:16] [Music] [0:18] you'll notice just the outro from all my [0:20] videos and [0:21] yeah that's what i use is my outro let's [0:23] say i want to convert it [0:24] to an mkv for example well i have a [0:27] program named [0:28] ffmpeg and if you're running linux and [0:30] you have a desktop environment installed [0:32] this is already on your system including [0:34] all the codecs that are going to need to [0:36] do all the conversions [0:38] so let's say i want to convert this file [0:39] so i'm going to do ffmpeg-i [0:42] outro so i means input and if i don't [0:45] give it any [0:45] any other parameters and just press [0:47] enter it will give me information on the [0:50] file [0:50] so as you can see here it tells me that [0:52] um stream00 [0:54] it's using the hevc encoder which is a [0:57] modern functional [0:58] encoder you 420p like pixel format [1:01] it's at 1920 by 1080 in terms of [1:03] resolution it's at 60fps [1:05] and all of the stuff for audio it's [1:06] using aac it's a 48 [1:09] 000 hertz sample rate stereo and 128 [1:13] kilobytes per second as the bit rate um [1:15] so yeah all of that stuff [1:17] now let's say i want to convert it to an [1:18] mkv without [1:20] any parameters fmpeg defaults to a bunch [1:22] of stuff that it has pre-built in it [1:24] i can just tell it to convert it to [1:26] outro dot mk so it might take a little [1:28] bit of time because this is [1:30] a 20 second long video but eventually [1:32] after i've done running this command so [1:34] outro that mp4 [1:35] auto mkv just specifying i want it to go [1:38] from this is my input to just this [1:40] output [1:40] i get an output and if i double click [1:42] and play this [1:45] you'll see it's it's pretty much the [1:46] same thing now what if i want to specify [1:48] a different encoder so [1:50] this used h264 as the encoder because by [1:53] default [1:54] ffmpeg will try to use h64 when [1:56] converting things to mkv [1:58] let's say i want to use um h265 or hevc [2:03] i can do dash c v [2:07] and specify lib x265 [2:10] as my video codec same for audio if i [2:13] want to use aac for example which is [2:15] higher quality [2:15] lossless audio i can do dash c colon a [2:20] aac i can give them more options [2:23] so for example i want to scale the video [2:25] i can do dash [2:26] s and like 1280 x 720 [2:30] that's 720p let's say i want to give it [2:33] a rate i'll i'll keep this for now [2:35] in the meantime before i talk about more [2:37] options i'm going to quickly um [2:40] run this and cancel it so i have it [2:41] saved i'm going to talk about how to [2:44] actually get the encoder list so [2:46] you saw me write out lib x265 how do i [2:48] know what all the encoders are well if [2:50] you want to see all the encoders [2:51] you do ffmpeg dash encoders [2:54] and that will print them all out if i [2:56] want all of those to go to like a file [2:58] just do ffmpeg [3:00] encoders and send them over to like i [3:02] don't know [3:02] [Music] [3:04] encoders.txt so there you go [3:06] and it will create encoders.txt you can [3:08] look through these uh [3:09] and there's all the encoders you can [3:11] possibly use on a system [3:12] now not all of these might work with [3:14] your system maybe you don't have the [3:15] hardware for some of the some of these [3:17] or your processors too old or [3:19] or maybe they're just not supporting [3:20] enough that certain things downloaded or [3:22] something like that [3:22] but most of these should work and the [3:25] reason all of these are here is because [3:26] video comes in many variations so the [3:28] one i use [3:29] was let's see if i can spot it here we [3:31] are uh lib [3:33] x265 so this is s265 also known as hevc [3:38] uh h264 this is the nvidia version but [3:41] up here [3:41] we got h64va api so that's the version [3:44] for um video accelerated stuff [3:47] um and then somewhere up there here we [3:50] are you'll find [3:50] libx 264 so that's h64 so that's the [3:53] actual you know [3:54] standard codec anyway but this isn't [3:57] what's important now let's go back to [3:58] where we were uh before i think i need [4:00] to go [4:00] uh wait a second you know open up the [4:03] main toolbar [4:04] and not maintain sorry uh settings uh [4:07] show tabs go back to the previous file i [4:09] was in [4:10] this one anyway so back to what i was [4:12] talking about before [4:13] let's say i want to take i don't know [4:16] let's just delete this file let's say i [4:17] want to take [4:18] outro that mp4 and convert it uh with [4:21] what i was doing before [4:23] uh this um i want to use aac as my audio [4:26] codec [4:27] x265 as my video codec basically the [4:29] best ones out there pretty much [4:31] and i want the resolution to be 720p [4:34] let's say i want to [4:35] change the audio rate so rate colon [4:38] a and i give it something like 44 [4:42] 100 a common audio rate uh just [4:45] give it a couple spaces so things are a [4:46] little bit more evenly formatted here [4:48] um spaces don't matter let's say i want [4:50] to change the [4:51] video bit rate dash b the one megabyte [4:55] at most it can reach one megabyte per [4:57] second [4:57] most likely won't but if i really want [4:59] to uh or let's say i want the audio [5:01] bitrate to be something i can do [5:03] dash b a and bitrate audio and set it to [5:05] 192 kilo [5:06] kilobytes per second or kilohertz no not [5:09] killer it's kilobytes per second [5:11] um now setting video like uh bitrates is [5:14] pretty pointless when you're using [5:15] something like x365 or h264 all that [5:17] stuff because there's already an inbuilt [5:19] utility for it it's called [5:20] crf and it's much better it's uh very [5:23] varying the bit rate [5:24] uh based off a number you give it so the [5:26] lower the number is [5:27] the better the quality will be but the [5:28] bigger the following follows [5:30] so let's say i want it to be 24. 24 is a [5:34] good number uh i [5:35] most of my videos are you know 20 i set [5:37] the crf rate to 24 when i compress them [5:39] including this one it's 24. and um [5:43] you know as you can see it looks pretty [5:44] good if you need higher quality [5:46] 20 but like it's pretty [5:48] indistinguishable like a little bit [5:49] maybe with more noisy video but you know [5:52] for most video it's perfectly fine [5:53] anyway moving on let's say i want to [5:56] change the duration as well this video [5:58] i can do dash ss to declare what i [6:00] wanted to start i wanted to start at [6:01] well zero hours zero minutes zero [6:04] seconds [6:05] and zero milliseconds and let's say i [6:07] want it to end so dash [6:08] t at zero hours zero minutes [6:12] and zero five seconds and zero [6:14] milliseconds [6:15] i can also that's pretty much it no so [6:18] i'm going to do after outside mp4 i'm [6:19] going to use x265 i'm going to set my [6:21] codec to aac for audio [6:24] i'm going to scale it down to 720p [6:26] change the audio bitrate to [6:27] 44 100. i use crf 24 so you know pretty [6:31] good quality for [6:32] h.265 and stuff set my bitrate of audio [6:35] to 192 kilobytes per second [6:37] uh start the video at zero zero just the [6:40] beginning of the video [6:41] and end it at five seconds so let's [6:42] press enter and let it work [6:49] since it only had to do five seconds it [6:50] was relatively quick and if we play this [6:52] back [6:56] as you can see it lasts five seconds [6:58] it's in 720p and [6:59] everything has been applied so ffmpeg is [7:02] a really powerful tool when you want to [7:03] mask convert files because you could [7:04] just write a script and and mass convert [7:06] every single mp4 file to [7:08] a different format or every single mp4 [7:10] file compress it to something else or or [7:12] something like that [7:13] and let's say i want to take this [7:15] outro.mp4 file [7:16] and turn it into audio well that's the [7:18] same concept dash i [7:20] altered it before if i want to specify a [7:22] specific audio codec i guess i don't [7:23] know [7:23] lib opus or something but i'm just going [7:26] to say outro dot wav [7:28] let's just turn it into a waff instantly [7:30] done there you go australia double click [7:32] that [7:34] and as you can see it plays back because [7:36] i've converted it to audio [7:37] and here right before i end this video [7:39] because i've talked about all the main [7:40] options [7:40] let's do a fun little experiment let's [7:42] transform this outdoor.web and this [7:44] image into a video [7:45] so i'm going to take out that wav and [7:48] essentially mix it with this image so [7:49] i'm going to do ffmpeg [7:51] dash i outro [7:54] and then dash i image.png and i'm going [7:58] to specify [8:00] a specific codec so let's say i want [8:03] libx265 relatively good the crf [8:06] i don't know 20 [8:10] 20 20 is pretty good in terms of quality [8:12] images are a little bit messed up when [8:13] it comes to this kind of stuff [8:15] and let's say i want um something like [8:18] uh [8:19] audio codecs okay i might want to [8:21] specify a bitrate for audio though so [8:23] i'm going to do b [8:24] a and set it to 192 kilohertz so let's [8:27] press enter on this [8:29] and oh yeah i forgot to set an output [8:31] file so wait a second i'm going to [8:33] specify i want it to be [8:34] outro image dot mp4 press [8:37] enter and just let it convert there you [8:38] go it's already done double click on [8:40] this [8:41] and as you can see it's the image with [8:43] the audio it's just you know the image [8:45] playing back in it and it has the audio [8:47] from uh outro dot uh wove which is just [8:50] you know just the raw [8:51] 20 second audio and it mixes it with [8:54] this image so if you've ever wanted to [8:55] just have a still image [8:56] and you're talking you can make that [8:58] pretty easily in the file itself is [9:00] negligible in terms of sizes it's [9:01] minuscule it's 489 kilobytes so if you [9:05] ever need to make a video where it's [9:06] just like [9:06] an image and that's all you can do that [9:08] pretty easily with this [9:10] so anyway thanks for watching my video [9:11] on how to use you know ffmpeg with some [9:13] basic options [9:14] i'll have all a bunch of examples in the [9:16] description if you want to take a look [9:17] at them i'll just have this entire thing [9:19] in the description actually [9:20] um and yeah ffmpeg is a really useful [9:23] tool i recommend if you're into video [9:24] stuff [9:25] you learn how to use it uh the best [9:27] encoders for video [9:28] are at the moment lib x265 [9:32] best encoder for audio is aac because [9:34] high quality [9:35] x265 is you know as long as you set your [9:37] crf rate appropriately it's going to be [9:39] perfectly fine in terms of quality [9:40] might be a little slow because [9:42] processors and stuff um if you need to [9:44] deal with [9:45] something like nvidia and coding you can [9:47] do obviously what was it called um [9:50] nvenk uh underscore hevc that's another [9:54] codec you can use but it's it's or [9:56] actually i think it's hebc underscore [9:58] and bank [9:59] and it's it's fast but it isn't as [10:02] precise because [10:03] gpus aren't like perfect like processors [10:05] when it comes to video and [10:06] the file sizes will be larger and it [10:08] won't be as you know good [10:09] it won't be as high quality video but [10:11] yeah that's pretty much it [10:13] thanks for watching my video goodbye [10:25] [Music] [10:35] you