FFmpeg Crash Course | Install, Convert, Reduce File Size, Trim, Crop, Watermark, Chroma Key, Overlay

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i will give you an ffmpeg crash course and show you how to install it on different platforms and how to use it to convert video files into different formats reduce file sizes add and extract audio from and to video files trim crop watermark chroma key and overlay video files with each other so let's go welcome everybody i'm happy to have you here again i'm cons your diy stream tools creator and ffmpeg is a free and open source project which includes a lot of libraries for vu and multimedia editing i actually use it almost daily and i think it's a great tool every content creator should know and should know how to use it however it's a command line tool which makes it a little bit tricky to use but for that i'm here and i will show you now how to install it on windows mac os and linux so let's get started with windows so to install ffmpeg on windows first you have to go to the ffmpeg website for which you can find the link down below in description then click on download choose windows and go to one of those sites i'm using the builds by btbn click on that and here you find the latest versions of ffmpeg make sure to download one that has is not shared so i'm going to download the win64 gpl.zip when the download has finished head into your downloads folder and right click on the downloaded zip archive click on extract all and extract the ffmpeg binary from the zip archive and now in here we have bin and dock we just renamed that directory real quick we call it ffmpeg then we're going to open a new explorer window and we head into our program files c program files and just move that ffmpeg directory in here now we have installed ffmpeg on windows but in order to use it in our command line without always entering the path to the binary we have to add the binary to the path of the windows command line for that we go into our search enter environment and go to edit the system environment variables in here we go to the advanced tab and go to environment variables here we see all the environment variables that windows currently has and we want to edit the path variable so we click on that and go to edit and in here you can click on new and add a new variable i already added the path to the ffmpeg binary which is under c backslash program files backslash ffmpeg.bin and if you're done with that we click on ok ok and now ffmpeg is accessible through the ffmpeg command in our command line to install ffmpeg on mac os we're going to use the package manager brew which you can use from the command line as well and it's super easy you just type brew install ffmpeg and press enter and that will automatically install ffmpeg onto your computer and also set the necessary path variables such that the command line can later find the ffmpeg command and last but not least here's how you can install fmpeg on a linux system that is based on debian or ubuntu linux so we first go into our terminal and in the terminal we are going to enter zero opt update press enter enter our password and when the update is finished we are going to enter sudo opt install ffmpeg and that will install ffmpeg onto our disk and also add the ffmpeg binary to the path variable such that we can use the ffmpeg command in the command line and now to how we can use ffmpeg the first part is how we are going to convert one format into the other so in order to use ffmpeg we need the command line so we're going into the command prompt and then we are going to the folder where we have stored our video files that we want to convert i already prepared several video files over here and in order to get into that folder with the command line we enter we type cd and then we copy the address from the explorer and enter that in here and press enter when we press dear we can see all the files in the directory an ffmpeg command is always built out of three main components first the ffmpeg command itself then followed by minus i which states the input file and for us this is in this example input dot mkv and then in the end of the fmpeg command comes the output file and at the moment we just want to convert the input mkv to an output mp4 so we enter output dot mp4 and press enter and with that ffmpeg will start converting that mkv file into an mp mp4 and now we can have a look at the mkv still works and we can also have a look at the mp4 and that is basically the same video that is due to the fact that mkv and mp4 are not converting the videos into different codecs they're just container formats containing videos in different codecs if we want to change the codec of a video file or audio file we have to add more to the ffmpeg command in our next example we are going to convert the video file into the vp9 codec and the audio contained in that container into the verbis ogg format so we enter ffmpeg minus i input mkv and then we enter c colon v which means codec for video and we enter our codec which is vp9 then minus c colon a lib vorbis which is the codec for our audio and then the output file which is again output and this time we're going to store it in a web m-file so we enter web m and press enter and this will convert our video from the recorded x264 codec into the vp9 video codec and our audio from the mp3 codec into the verbis ogg format and when we have a look at our output file we have now an output webm file and we can also have a look at that and it still works as well but sometimes we might only want to convert the video to a different codec and keep the audio for that we're going to enter ffmpeg minus i input mkv c minus c colon v and we stay with the vp9 codec but we want to keep the codec of the audio so we enter c colon a copy which which will only copy the audio track to the new container format and then we again state the output file with output dot web m and press enter but sometimes we only want to convert the audio codec to a different format and keep the video as it is for that we're going to enter ffmpeg minus i input mkv and then we enter c minus c colon v and enter copy which means we're only copying the video file to the new container format and for the audio codec we enter minus c colon a lib warbiz and then convert that into the output mkv and press enter when you want to upload your videos to a certain online service they usually require you to stay below a certain resolution or file size so in this part i'm going to show you how to reduce the bitrate frame rate and resolution of the video so we start again with ffmpeg minus i input mkv and we want to copy the audio with c colon a copy and for the video we're going to enter c colon v lip x 2 6 4 and then minus b which stands for bit rate colon v which stands for video and we want to reduce it to 1 megabit and then we state the output file again output mp4 and press on enter and when we now compare our input mkv which has a file size of 46 megabytes to our output mp4 which only has a size of 908 kilobytes we can also make a quick comparison this is the input and this is the output the frame rate is actually pretty drastically reduced so you have to play with the values in order to get the result you want to achieve the next thing is we want to reduce the frame rate in order to reduce the file size for that we're going to enter almost the same command but this time instead of minus b colon v we enter minus r and enter a frame rate of 24 this video the input mkv is recorded in 60 fps and now we are going to reduce it to 24 fps in the output and press on enter and when we now have a look at it it has a much better quality however it's a little bit stuttery because we reduce the frame rate to 24 and last but not least we also want to reduce the frame rate of a video so we enter the same command as before but instead of minus r we enter minus s and then the resolution of the output file for us this is 848 by 480 pixels which is roughly the resolution of a 480p video and then we press on enter and that will convert our video down from the 1440p video which was the input file to a 480p video so we have a look at that as well and we see the video is much smaller and when we compare the output size as well it's only 621 kilobytes and we can also combine all those values so we can enter the command again we reduced the bitrate with minus b colon v to 1 megabit we reduce the frame rate to 30 frames and the size to 480p and then we press enter and that will convert it into the video we have stated and we can have a look at that and that is actually a pretty high quality 1480p video even though it is only 800 kilobytes in size maybe we only want a certain part of our video so it's 10 seconds in the middle so we have to trim it so we once again enter ffmpeg minus i input mkv and we have to set a start point from where we want to start our cut with minus ss and then we say it is at 10 seconds and then we have to state the length of the video in seconds we do this with minus t enter a 10 this is 10 seconds from the start point we have just set and enter the output mkv again and that will cut out 10 seconds of the video starting from the 10 second point now we only want the audio part of the video so for that we have enter once again ffmpeg minus i input mkv minus vn which means no video and then as an output we say output dot mp3 and press enter and that generated a mp3 which only contains the audio of our video we cannot only extract audio from a video files we can also add additional audio to our video files for that i'm going to enter a slightly more complex command which is always starting with ffmpeg minus i input mkv and then minus i audio m4a which is the second input file which is the audio file we're going to add to our output then we use the map command which says that we are going to map the first input argument to video and to the first slot in our output file and then the second map command is one colon a colon zero which means that we use the second input argument which is our audio file and map it to the first slot in our output file then we copy over the codec and state our output file and press enter but maybe the audio file we are adding is too loud for a video so for that we are going to add a filter with minus filter a and then volume and we want to reduce the volume to 0.5 so we enter volume 0.5 and press on enter and this will add the audio file with half the volume to our video we can also increase the volume of our already existing video file with this command ffmpeg minus i input file and then minus filter colon a volume and then we enter 2.0 which will double the volume of our audio in our output file sometimes only a part of a video is interesting so we're going to use ffmpeg to crop the video for that we're going to use a video filter with minus filter colon v crop then we enter the dimensions of the cropped video file and the start point zero zero means we are going to start our crop from the upper left corner so when we press enter and then have a look at the finished result of our output file we see it only displays the upper left hand corner of our video sometimes you want to share your video project with someone else but you also don't want that they use your work so for that you're going to add a watermark and with ffmpeg we're going to add a watermark with ffmpeg minus i input file minus i the path to our watermark we have over here which is a png then a minus filter underscore complex overlay equals 50 colon 50 which means that our watermark is placed 50 pixels from the top and 50 pixels from the side and then of course the output file and we press enter and when we have a look at the finished video file we can see that it now has my logo on top as a watermark in one of my previous videos i showed you how to make a custom stream alert using powerpoint which you should totally check out over here and that generated a file which includes the follow alert but also this green background and we are now going to use ffmpeg to remove this green background and replace it with transparency for that we are going to use this command first we of course have our input file and then we need to choose a codec that supports transparent video which is the vp9 codec then we add a filter with minus filter colon v and the filter we are going to use is the chroma key the first parameter of the chroma key filter is the color and this is green so we use zero zero ff00 which is the hex representation of green then the tolerance so how much tolerance should be used when replacing the green so if our green is not exact the the color we have stated here the tolerance will help with a better result and then the blend value which also can be adjusted and usually helps with getting a better replacement of color but you always have to play around with the values a bit to reach result you want and then as an output file we're going to use a webm container because that supports the vp9 codec and when we have a look at the finished result of our webm file we see now that the green background is replaced by a transparent background last but not least we want to overlay one video with another video and for that i created a slightly smaller version of the input mkv which is only 480p that file is called input 2 mkv and with the following ffmpeg command we're going to use it for a picture in picture mode so we have ffmpeg minus i input mkv minus i input 2 mkv which is a smaller file then we're going to use a complex filter and those two brackets with zero v and one v correspond first to the input mkv and then we're going to overlay that with the input 2 mkv and the overlay will be inset by 25 and 25 pixels from the top and from the left hand side and when we execute that and have a look at the finished result we can see that the smaller video is now overlaying the larger one and we have this picture in picture mode going on here you can of course find all the commands i have shown in this video down below in the description i hope this video was helpful for you and you can now start using ffmpeg if you got any questions about ffmpeg put them down below in the comments if you enjoyed this video make sure to like and subscribe for more upcoming videos like this one big shout out to my patreon subscribers for their support if you also want to support me in making those videos consider signing up for my patreon for only one euro a month which gives you early access to all my videos you can also find me on twitch if you want to talk about tech streaming diy and content creation and do not forget to join my discord server with this i wish you a fantastic day and as always build explain enjoy bye-bye oh oh what's what's going on marny helicons you see this cat here it's a stray cat i love it um don't you think this farm could use a good cat of course give me the cat guys what should we name the cat
Info
Channel: k0nze
Views: 4,219
Rating: undefined out of 5
Keywords: FFmpeg, Konze, k0nze
Id: yieG9DZQ_vM
Channel Id: undefined
Length: 18min 40sec (1120 seconds)
Published: Fri May 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.