If you’re anything like me, your first tentative steps away from GUIs to mighty CLIs can be intimidating. The internet is full of programs that claim to be able to do what you’re imagining but you cant get any of them to run, or talk to each other or anything.
There must be hundreds of guides like this out there. This is mine, and I’ll try to write it in a way that would have helped me out when I first started playing with FFmpeg. Hopefully this guide will help you and won’t be too long and boring. If you want to skip to the installation steps click here. I an not a developer. I may unwittingly use incorrect terminology and if I do then please feel free to correct me in the comments below. I would really like this to be a useful and acurate guide.
I think of FFmpeg as a program which contains loads of different video and audio codecs (e.g. x264, x265, lame, AAC etc), editing tools (e.g. cropping, rotating etc) and muxing tools (wrapping in your format of choice (e.g. mp4, mkv, avi, mp3), embedding sub-titles and meta data etc). FFmpeg is capable of doing a whole lot more too but I can’t claim to understand all of it.
There are some codecs that aren’t included with the version of FFmpeg that most of us will download. I believe this is because these codecs aren’t open source and need to be paid for. They include commercial codecs like h264 and if you really need them, I believe that you can compile your own FFmpeg distributable.
What FFmpeg doesn’t do is give you a sexy timeline where you can drag and drop your AV clips, add/remove AV clips in real time, get real time previews etc. I think that these programs are called non-linear editors and include expensive examples like Adobe Premiere. I think programs like Lightworks allow free licenses and provide friendly interfaces, but I dont have much experience with these packages.
So based on that I guess FFmpeg might be called a linear editor? More information can be found at https://ffmpeg.org/, particularly under documentation. There is also a ton of info at https://trac.ffmpeg.org/wiki and of course, Google is your friend in this endevour.
What FFmpeg does very well is provide a no frills tool for achieving countless media file manipulations. It’s an invaluable free tool and comes without the overheads required by fancier GUIs. Also it’s under constant development which means that new technologies are being added all the time. For general use however, I dont really bother to update every version.
FFmpeg is not packaged in an installation file. What I mean by that is: don’t double click your downloaded .exe or .msi file (see here for making windows show you your file extensions) and expect a bunch of files to automatically be copied into useful places, all kinds of clever entries to be entered into your registry and pretty icons to be put on your desktop and in your start menu.
FFmpeg is a stand-alone program. What that means is that you download a file, or series of files, some of which have .exe extensions. If you double click on these files they will actually run a program, not install it. In the case of programs like ffmpeg.exe, if you double click it, a small black window with white writing will briefly flash on your screen. That’s because FFmpeg doesn’t have a GUI. You need to open your command line interface (think old school DOS prompt if you can remember that) and run it from there. The small black window will stay open that way.
The CLI presents a series of challenges to the uninitiated, none of which are insurmountable. Two primary ones are:
- Telling Windows where the ffmpeg.exe file is. The command line is simplistic in this sense. If you’re in a particular folder, say c:\temp, type in ffmpeg and press enter, Windows will first look for the ffmpeg.exe file in c:\temp. If it cant find it there, it will look through a preset list of folders. This list is stored in a variable called the Windows path. Lets say I have copied the ffmpeg.exe files to a folder called c:\Program Files\ffmpeg\bin. If that folder name (c:\Program Files\ffmpeg\bin) is included in the Windows path variable, Windows will find ffmpeg.exe and be able to run the program. If ffmpeg.exe is not in c:\temp and the folder name is not in the Windows Path, Windows will tell you that it doesn’t recognise the program name. More on changing your Windows Path later.
- Telling ffmpeg where your media files are. I generally use ffmpeg for making timelapse clips. For these clips i have lots of .jpg images. If I have added ffmpeg to my windows path, I can simply navigate to my .jpg file list (e.g. F:\timelapse_projects\project_folder\source_images) and execute the ffmpeg command from there. If the path is not set up correctly I will need to point the command line to one or both of ffmpeg and the images. For example:
Without setting up windows path:
"C:\Program Files\ffmpeg\bin\ffmpeg.exe" -i ^ "F:\timelapse_projects\project_folder\source_images\tl_%03d.jpg" ^ "F:\timelapse_projects\project_folder\timelapse_clip.mp4"
With correctly set up windows path:
cd F:\timelapse_projects\project_folder ffmpeg -i source_images\tl_%03d.jpg timelapse_clip.mp4
This is important because command lines can get long and easy to make mistakes with. This is a very simple example and generally there will be more options included. e.g.
ffmpeg.exe -fflags +genpts -threads 4 -y -i source_images\tl_%03d.jpg ^ -pix_fmt yuv420p -flags +loop -g 250 -keyint_min 25 ^ -metadata:s:a:0 title="English" -metadata:s:a:0 language=eng ^ -flags +global_header ^ -c:v libx264 -preset slower -tune film -crf 20 -level 3.1 ^ -vf "crop=in_w:in_w*(9/16),scale=1920:1080" ^ -sws_flags lanczos ^ timelapse_clip.mp4
I split these examples onto multiple lines with the ^ character but it is clear that simplification of the command, where possible, can be useful. Additionally, I used quotes to surround certain phrases. This is important for paths with spaces in them e.g.
Right, after all that droning, lets get FFmpeg installed and running properly.
Copy the FFmpeg program files to their new home
- In your browser, go to https://ffmpeg.zeranoe.com/builds/ and download the latest static build (Version: git-9486de5 (2016-05-10) at time of writing).
- Extract the contents of the .7z file to somewhere you can find them (if you dont have an archive manager try http://www.7-zip.org/ (free and works great).
- Rename the folder from e.g. ffmpeg-20160510-git-9486de5-win64-static to ffmpeg. The important .exe file(s) are now in a folder called bin (for binary) inside your ffmpeg folder.
- Copy the whole ffmpeg folder to your c:\Program Files folder. Actually it doesn’t matter too much where you copy it to, just as long as you don’t delete it later and you know where it is. I like putting it in c:\Program Files to keep c:\ neat.
Update your Windows Path to include your FFmpeg folder
Be careful here. It is simple enough but you can mess things up if you do strange things to your Windows Path variable. If you carefully follow the instructions you should be fine though. I don’t know if I need to say this but I dont take any responsibility for any screwups in this regard.
There are lots of guides for this, here is one. I’ll briefly run through a Windows 7 example.
- Click the Windows Start Orb > right click Computer > left click Properties.
- In the window that pops up, in the left hand pane click Advanced system settings.
- In the new dialogue, if necesarry select the Advanced tab and near the bottom click Environment Variables…
- In the bottom pane of the Environment Variables window, if necesarry, scroll down to the Path variable.
- The Edit System Variable dialogue opens BE CAREFUL!:The Variable Value text box contains the
;separated list of paths that Windows will search through to find your ffmpeg.exe file. You will add the folder where your ffmpeg file lives to the search list. Be careful not to change anything else though as this can break stuff!
- In the Variable Value text box to the right add the following to the very end:
- If you copied your ffmpeg folder somewhere else then use your path. Dont forget the
- Click OK > OK > OK to close all the dialogues.
FFmpeg should now be installed! Well done! Let’s test it.
- Click the Start orb.
- In the “Search Programs and Files” text box type
- Hit enter or click cmd in the list of results and the windows command prompt window should appear. In the window you can see which folder you are currently in, eg c:\Users\yourname
- At the flashing cursor
_, type in ffmpeg and hit enter.
If all went well and FFmpeg’s location was added to you path correctly you should see some output like this:
If there was a problem, your output might look more like:
'ffmpeg' is not recognised as an internal or external command, operable program or batch file.
That’s telling you that windows cant find ffmpeg.exe. In this case, review the steps above, particularly WRT adding the correct path (e.g. C:\Program Files\ffmpeg\bin) to your Windows Path variable.
Good luck, I hope this helped.