Open main menu

Wikibooks β

FFMPEG An Intermediate Guide

FFmpeg is a free software project that produces libraries and programs for handling multimedia data. FFmpeg includes libavcodec, an audio/video codec library used by several other projects, libavformat, an audio/video container mux and demux library, and the ffmpeg command line program for transcoding multimedia files. FFmpeg is primarily published under the GNU Lesser General Public License v2.1, and some components may be licensed under the GNU General Public License v2.

Unfortunately, the documentation can be scary even for a beginner, so this book will guide you through the basics of using FFmpeg. It includes best practices, defines concepts and includes some problem solving too.

Feel free to help develop this book.

Index

Contents

The BasicsEdit

Getting startedEdit

FFmpeg is a command line audio and video transcoder. You need to be at the command line/terminal if you want to use it. However, you can install a graphical shell if you prefer. See the Installation section for more info.

At its very basic, FFmpeg takes an input file and encodes it to an output. These files can be anything you want, in any location you want.

 ffmpeg -i input.avi output.mp4

Let's go through each part of this line to see what they mean:

  • ffmpeg

Here, we're asking in our environment path or folder for a program called FFmpeg to run. If you get a message that is synonymous with "ffmpeg not found," it means you either need to run FFmpeg in the same folder or move it to a folder that's set to your command-line's environment path. This is covered in the Installation section for each system.

  • -i

This is a flag that tells FFmpeg to use a value for it. In this case, i means Input. We want to tell FFmpeg where our input file is located. Be absolutely sure that you include the extensions as well.

  • output.mp4

Then, we just tell FFmpeg where to put the resulting file. In this example, we don't explicitly tell FFmpeg what format to use, so when we type an extension in the output, it assumes we want to use the closest matching result (in this case it would be MP4).

Notice how FFmpeg expects a new command/setting after each space is put in. If you want to point to a location where a folder or file has a space in it, put quotation marks around the path, as shown in the example below. It's not normally necessary where spaces aren't prevalent but it is a requirement otherwise.

 ffmpeg -i "video 2011-05.mpg" -b 3000k "video 2011-05.mov"
  • -b

This is another flag that tells FFmpeg how many bits the video should put into each second of playback. A higher bitrate does not always mean higher quality.

Now that you know the basics of creating a video file in FFmpeg, you can move on to more sections. I personally recommend working with audio first to get a feel for customization there.