How To: Setup and Use ffmpeg on Windows
I am not going to bore you with explanations of what ffmpeg is or it's history. We're going to jump right in.
How to Get ffmpeg for Windows.
There maybe several places to get the Windows Binary (Program) Files but I have had great success with the builds from FFmpeg at Zeranoe.com. If you haven't already; open a new window or tab using this link:
You can choose between either 32-bit or 64-bit Static or Shared Builds. I am using Windows 7 64-bit Ultimate so I chose the 64-bit Static build. I went with the Static build because everything is included in the executable file. I don't have to worry about external dll files. (just my personal preference.) Which ever version you decide to download, make sure you know where the downloaded files are placed. I suggest to right-click on the link to the file you want to download and from the context menu choose “Save Link As...” or “Save target as...” depending on which browser you are using. That way you can specify the download location.
Note: If you are using a 64-bit version of Windows, I suggest you get both the 32-bit and 64-bit versions. I personally use both versions on my Windows 7 64-bit Ultimate desktop machine.
The files are zipped using 7-Zip which you will need to use to extract the files. You can download it for free here if you don't already have it. (This is a great utility, I highly recommend it. I use it quite frequently.)
Setting up ffmpeg.
If you are using a version of Windows that has UAC (User Access Control) (i.e. Vista or Windows 7), before extracting any files or opening the archive, you may want to perform the following action: Right-click on the downloaded file and click on ‘Properties’. Click the ‘Unblock’ button located near the bottom right of the dialog box then click ‘OK’. (You should only have to do this once per downloaded file and only if you know and trust the source of the file you downloaded.)
There is no Windows installer included in the builds so we need to decide where to put the program files. I chose to use the Windows standard location of “C:\Program Files\”. You may choose your own location. Just make sure to use the location you have chosen in the following steps. Before you begin, make sure you have 7-Zip installed and you have the 7-Zip options available on the context menu by right clicking a file in Windows Explorer.
- In Windows Explorer, right-click on the 7z file you downloaded and choose ‘Open archive’ under 7-Zip.
- From the 7-Zip dialog box, Choose ‘File’->‘Rename’ or just press the F2 key on your keyboard.
- Type “ffmpeg” and press ‘Enter’. Do Not Close the archive. There should only be one item showing now and the name should only be “ffmpeg”.
- Click on the ‘Extract’ icon (second on the left)
- Click on the ‘ ... ’ button at the far right.
- Choose “C:\Program Files\” and click ‘OK’.
- If the ‘Copy to:’ box has the correct path, “C:\Program Files\”, click ‘OK’.
-
Close the 7-Zip archive.
- If you are using a 64-bit version of Windows and you want to use both the 32-bit and 64-bit versions, use the same steps above. Pay close attention to the archive file name. The 64-bit version should go to “C:\Program Files\” and the 32-bit version to “C:\Program Files (x86)\”
If all went well, you should now have a “ffmpeg” directory under “C:\Program Files\” with the following sub-directories: “bin”, “doc”, “licenses”, and “presets”. There should also be a “README.txt” file. We are going to add a batch file to the “ffmpeg” directory.
- In Windows Explorer, navigate to the “C:\Program Files\ffmpeg” directory.
- In a blank area away from any file or directory, right-click in the details (right-hand) pane and click ‘New’ -> ‘Text Document’
- Type “ffmpeg32”. DO NOT PRESS ‘ENTER’ YET!
-
Replace the ‘.txt” extension with “.bat”. The file name should look like this: “ffmpeg32.bat”. Now press ‘Enter’ and answer ‘Yes’ to the ‘Rename’ dialog box confirming you want to rename the file.
-
If you are setting up both the 64-bit and 32-bit versions, name the batch files as follows:
- 64-bit:
- “C:\Program Files\ffmpeg\ffmpeg64.bat”
- 32-bit:
- “C:\Program Files (x86)\ffmpeg\ffmpeg32.bat”
-
If you are setting up both the 64-bit and 32-bit versions, name the batch files as follows:
Now we need to edit the batch file we just created. You can use your favorite text editor for this. I recommend just using Notepad.
- In Windows Explorer, right-click on “ffmpeg32.bat” and click ‘Edit’.
- Type “@ECHO OFF” (without the quote marks) and press ‘Enter’.
- Type “C:\Program Files\ffmpeg\bin\ffmpeg.exe” (include the quote marks) DO NOT PRESS ‘Enter’ yet.
- Press your space bar once to add a space after the quote mark.
- Type a percent sign (%) located above the number 5 on US keyboards.
-
Type a asterisk (*) located above the number 8 on US keyboards.
You should have two lines of text as shown below:@ECHO OFF
"C:\Program Files\ffmpeg\bin\ffmpeg.exe" %*
-
Save the file and exit Notepad.
-
If you are setting up both the 64-bit and 32-bit versions, the batch files should look like this:
- 64-bit: “C:\Program Files\ffmpeg\ffmpeg64.bat”
-
@ECHO OFF
"C:\Program Files\ffmpeg\bin\ffmpeg.exe" %*
- 32-bit: “C:\Program Files (x86)\ffmpeg\ffmpeg32.bat”
-
@ECHO OFF
"C:\Program Files (x86)\ffmpeg\bin\ffmpeg.exe" %*
-
If you are setting up both the 64-bit and 32-bit versions, the batch files should look like this:
There is just one more step to this setup. We need to set the system path to include the new directory we added. This will make it more convenient to use ffmpeg.
Windows Vista and Windows 7 users:
-
If you have a ‘My Computer’ icon on the Desktop, right-click on it and click ‘Properties’. If you do not have a ‘My Computer’ icon, open the start menu and right-click on ‘Computer’ and click ‘Properties’.
- Or -
Press the Windows Key + R to open the Run dialog box and type the following command:control sysdm.cpl,,3
- Click the ‘Advanced System Settings’ link in the left column.
- In the System Properties window click the ‘Environment Variables’ button.
- In the ‘Environment Variables’ window, highlight the ‘Path’ variable in the ‘Systems Variable’ section and click the ‘Edit’ button. Move the cursor to the end of the existing entries and type a semicolon (;). Use caution here so you do not remove or replace anything that already exists. Add the path or paths to “ffmpeg”. Make sure that each directory is separated by a semicolon as shown below.
”...;C:\Program Files\ffmpeg;C:\Program Files (x86)\ffmpeg”
Use the path or paths appropriate for your system and chosen setup.
Windows 2000 and Windows XP users:
- If you have a ‘My Computer’ icon on the Desktop, right-click on it and click ‘Properties’. If you do not have a ‘My Computer’ icon, open the start menu and right-click on ‘Computer’ and click ‘Properties’.
- In the ‘System Properties’ window, click on the ‘Advanced’ tab.
- In the ‘Advanced’ section, click the ‘Environment Variables’ button.
- In the ‘Environment Variables’ window, highlight the ‘Path’ variable in the ‘Systems Variable’ section and click the ‘Edit’ button. Move the cursor to the end of the existing entries and type a semicolon (;). Use caution here so you do not remove or replace anything that already exists. Add the path or paths to “ffmpeg”. Make sure that each directory is separated by a semicolon as shown below.
”...;C:\Program Files\ffmpeg;C:\Program Files (x86)\ffmpeg”
Use the path or paths appropriate for your system and chosen setup.
Basic use of ffmpeg.
Since ffmpeg is a CLI (Command-Line Interface) Program, we need to open a command prompt and type the command line we want to use. Now that we have set the path and created our batch file we can easily use ffmpeg like this (make sure to use the correct batch file for the version you want to run, ffmpeg64 or ffmpeg32):Windows Vista and Windows 7 users:
- Open an Elevated Command Prompt Window by pressing the Windows Key + R and typing “cmd” (without quotes) in the ‘Open:’ box. DO NOT press ‘Enter’ or click ‘OK’. Instead, press CTRL + Shift + Enter. Answer affirmatively to any User Access Control (UAC) prompts.
- In the Command Prompt Window, type ffmpeg32 -version and press ‘Enter’
Windows 2000 and Windows XP users:
- Open a Command Prompt Window by pressing the Windows Key + R and typing “cmd” (without quotes) in the ‘Open:’ box and press ‘Enter’ or click ‘OK’.
- In the Command Prompt Window, type ffmpeg32 -version and press ‘Enter’
This should display the version of ffmpeg along with information related to the build. The next thing I would suggest you do is create a text file of the help output for your reference.
- Open a Command Prompt Window (same as above).
- In the Command Prompt Window, type c: and press Enter.
- Type cd\ and press Enter.
- Type cd C:\Program Files\ffmpeg and press Enter. Your command prompt should now display like C:\Program Files\ffmpeg>_ with the underscore blinking on and off.
- Type ffmpeg32 -? > ffmpeg_help.txt and press Enter. The greater-than character redirects the standard output of the Command Window to the file named ffmpeg_help.txt. The file is created in the current directory (‘C:\Program Files\ffmpeg\’). That is why we made sure we were on the C drive with step 2 and changed the directory (cd) to our ffmpeg directory in steps 3 and 4.
ffmpeg has many features and options, too numerous to cover here. I will try to cover more functionality in future articles coming soon.