FFmpeg – Start Here!

A few weeks ago, someone highlighted a glaring error in my Blog articles…. I mention a lot of FFmpeg commands, along with tips and tricks, but very little on how to actually start using it!

I hope this page will serve as a little helpful guide to your first usage of FFmpeg and may make things a little easier when referring to some of the commands and ‘recipes’ I have mentioned over the years. It should also give you a good grounding if you wish to look into FFmpeg further, or perhaps take a course in its use specific to FVA. FFmpeg is also utilized by many different types of software, so understanding the framework may help to identify further options.

Although written for Forensic Video Analysis, this may help anyone with an interest in Multimedia processing within a WINDOWS environment. (You can also utilize FFmpeg within Mac and Linux but this article will be Windows only)

2000px-FFmpeg_Logo_new.svg

FFmpeg is a Multimedia Framework. This means it is able to do pretty much everything you can think of when it comes to processing multimedia. To get the full ‘official’ rundown, take a look at FFmpeg’s ‘About’ page HERE.

For our needs, we need to play something, understand something and then process something. As a result, with this framework, it may be possible to use FFplay, FFprobe and finally FFmpeg to complete a task.

Where do I get it?

The quickest and easiest way is to go direct to Zeranoes Windows Builds.

http://ffmpeg.zeranoe.com/builds/

From here you will have a number of options, and these could be a little confusing for the uninitiated!…

Image 001

Static versions include all the libraries, wrapped up neatly inside the executable’s. These are the ones to use,… but what about 64 or 32 bit? If you are going to be running FFmpeg on a 64bit PC with a 64bit Operating System then use the 64bit. If you don’t know – then use the 32bit!

You will see that under the large grey Download button, there is a link to previous versions. This is important to remember as you may wish to review an older version build.

When you download the latest build, you will have it as a .7z compressed file.

Image 002

You will need compression software that can un-compress this format type, such as 7zip.

http://www.7-zip.org/

When you un-compress, you will have the option of where to un-compress to. One suggestion is to create a folder on your C Drive called FFmpeg – and then extract it to this location. When you download other, newer or older, versions, unzip them to this same folder.

You can see I have a number of versions…

Image 003

Inside the folder, you will find something like this…

Image 004

The Readme.txt gives you important information on the version number of all libraries and what is enabled within that specific build.

Inside the Bin folder, you will find the three executables; FFmpeg, FFprobe and FFplay, but we are going to make things a little easier and utilize the FF-Prompt.bat that is sitting in this folders root.

Create a shortcut to this .bat file and then place that shortcut, anywhere. You could have it on your desktop. I have mine within my FVA toolbar.

Image 005

I have renamed my shortcut to simply ‘FFmpeg’.

How do I use it?

When you click on this shortcut, the command prompt will open inside the FFmpeg folder. Your CMD Window will look similar to this… but may be with smaller fonts with the standard color.

Image 005

You can change the text and other settings by adjusting the window properties. Right click in the large window bar at the top and select properties.

As well as changing Font Size and Color, it is worth increasing the Window Buffer size. This ensures that large amounts of text, such as the list of codecs available, can all be ‘printed’ within the window and doesn’t get cut off.

Image 006

Lets now test our command prompt.. at the cursor, type ffmpeg 

To submit a command, you need to then press ‘Enter’

FFmpeg will run, but as you have not specified any process, a small help will display.

Let’s now create a small file, play it and then convert it.

Before we get into the commands, it’s important to highlight filenames and paths. When I show something like, “yourfile.avi” It has to contain the entire folder path. If you simply left it with the filename, the resulting file would be saved into the FFmpeg folder.

As a result, rather than typing out file paths, drag and drop is probably easiest to use.

To show this at work create a blank text file on your desktop called vid.txt

Then, in the FF Prompt window, type…

ffmpeg -f lavfi -i testsrc=duration=10:size=640×480:rate=30 -c:v rawvideo 

…then, after leaving a space after rawvideo, drag your vid.txt into the cmd window. Delete the .txt and rename the extension to .avi. Then hit enter.

The 10 second video file should appear in your desktop. You can play this now by typing ffplay and drag and dropping this video into the window. your command should look like this:

ffplay C:\Users\name\Desktop\vid.avi

Press Enter..

Your test video should play in a new window… something like this..

Image 7

We have created a test video, and then played it…. but what about converting it?

Again, I find the drag and drop method the easiest for entering my input and output. When you drag it in for your new output file, simply change the name or extension.

At the command prompt, type (and drag and drop)…

ffmpeg -i drag in the vid.avi -c:v h264 drag in the vid.avi (but then change the filename and extension to out.mp4

Your command should look something like this…

ffmpeg -i C:\Users\name\Desktop\vid.avi -c:v h264 C:\Users\name\Desktop\out.mp4

After pressing Enter, You now have a H264 version of the original uncompressed testsrc video.

There is a huge range of helpful information online and that is where I will be going next. For now though, you have FFmpeg up and running, and easily accessible on your PC….. you are ready to start!

FFmpeg – Help!

Advertisements
By Spreadys Posted in EEPIP

2 comments on “FFmpeg – Start Here!

  1. Pingback: FFmpeg – Help! | Spreadys.com

  2. David, In the line ‘ffmpeg -f lavfi -i testsrc=duration=10:size=640×480:rate=30 -c:v rawvideo’, replace the x between 640 and 480 with an * and all works fine

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s