How to build the ultimate media converter (no experience required)

DVD Styler
FFMPEG is the power behind many media conversion tools

It's the first rule of multimedia: files are never in quite the format you need. Maybe an application doesn't support a video, it won't play on your mobile, you get a picture, but no sound – there are all kinds of potential problems.

You could go searching for free software to convert video, audio or image files from one format to another – but it'll take a while, and you might have to try out several packages, many of which come with a stack of annoying adware.

What's more, a lot of this freeware doesn't actually carry out any conversions at all. Instead, many packages just act as a shell for the open source FFMPEG. You choose a file or two, and they get FFMPEG to do the actual work.

Fortunately, there's an alternative: forget the freeware, download FFMPEG yourself and just use that directly.

This won't be an option for everyone. FFMPEG is a command line tool, and it'll take a little thought and time to get it set up correctly – but don't let that put you off. Considering the complexity of what it's doing, FFMPEG has to be one of the easiest command line tools to use, and you'll be able to use many of its most important capabilities in just a few seconds.

ffmpeg documentation

The official FFMPEG manual is available online

Getting started

FFMPEG is available for download from the project site. There are various builds for Windows, Mac and Linux – 32 or 64-bit, static or shared – which is great if you know what you need. But if you're not sure, and just want something basic to try out on a PC, go to Zeranoe, then download and unzip the latest 32-bit static build.

Later, you might try out FFMPEG by double-clicking ff-prompt.bat in the folder you've just unzipped. But first you'll need to learn a few commands, and they can be as simple as this:

ffmpeg -i source.mov destination.mp4

That's the basis for video conversion, right there: FFMPEG will read the first (MOV) file name and export it as an MP4.

You need an FLV instead? Just use that as the extension:

ffmpeg -i source.mov destination.flv

No complex command line switches are required, at least not yet – FFMPEG is smart enough to figure out the file format you need from its extension. And it supports a very wide range of formats, too, including 3GP, AVI, FLV, MPG, MKV, OGV and more (FFMPEG's online documentation has the full list).

But it gets better, because the program doesn't only work with videos. FFMPEG can also convert audio files from one format to another:

ffmpeg -i source.mp3 destination.ogg

Again, all you need to do is provide an appropriate destination extension, like AAC, FLAC, MP3, OGG, WAV or WMA and FFPEG will convert to or from that format.

There's support for converting images:

ffmpeg -i source.jpg destination.png

This works with BMP, JPG, PNG, TIFF and others (again, the official documentation has the full list).

Of course you don't have to manually enter these commands every time, either. Most of our examples can be embedded in a script, making conversions as easy as a drag and drop (we'll cover a few batch file basics later).

ffmpeg local help

Enter FFMPEG -H at the command line for help on this program's many commands

Video slideshows

Simple format conversion is useful, but FFMPEG really starts to get interesting when you combine format types.

Here, for example, we're converting a video to an audio file:

ffmpeg -i video.mov audio.mp3

It's exactly the same syntax, the same rules (use the audio extension to define your export format), only this time the program is taking the soundtrack from our movie and saving it (without re-encoding, if possible) to the destination.

Another interesting option allows us to convert videos into animated GIFs:

ffmpeg -i video.mov animated.gif

That needs to be used with care – the GIF will be huge unless your source clip is low resolution and just a few seconds long – but it's still potentially very useful.

It's not much more difficult to extract the individual frames from a video, although again we'd only do this with relatively small and short files:

ffmpeg -i video.mov frame%d.jpg

Here FFMPEG is saving every frame from our video as a series of JPEGs, frame1.jpg, frame.2.jpg, frame3.jpg and so on.

If you'd really like to get creative, then it's even possible to create a video from scratch by using other source files. The basic principles are easy enough to understand:

ffmpeg -i picture.jpg -i music.mp3 myvideo.mp4

This time we're making a video with a single still image and a soundtrack (much like those YouTube clips with a song and a picture of the artist).

You can even create full video slideshows from a sequence of images. This can become a lot more complicated as you need to manually define the video details, but in principle you might use something like this:

ffmpeg -framerate 1 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4

Here we're building a video slideshow from sequential images and saving it as an MP4. (There's much more to this, and advanced users should check out the FFMPEG wiki for details.)

Mike Williams
Lead security reviewer

Mike is a lead security reviewer at Future, where he stress-tests VPNs, antivirus and more to find out which services are sure to keep you safe, and which are best avoided. Mike began his career as a lead software developer in the engineering world, where his creations were used by big-name companies from Rolls Royce to British Nuclear Fuels and British Aerospace. The early PC viruses caught Mike's attention, and he developed an interest in analyzing malware, and learning the low-level technical details of how Windows and network security work under the hood.