FFMPEG An Intermediate Guide
| This book may need to be updated to reflect current knowledge.
You can help update it, discuss progress, or request assistance.
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. The program and its libraries are also used around the world by companies and consumers alike.
The documentation can be scary and overwhelming for a beginner, so this book will guide you through the basics of using FFmpeg. It includes best practices, defines concepts and may also include some problem solving too. Feel free to help develop this book.
- Basic Transcoding
- Installing FFmpeg and GUI's
- Advanced Video options
- Audio options
- Advanced Audio options
- Subtitle options
- Audio/Video grab options
- AVCodecContext AVOptions
- AVFormatContext AVOptions
- SWScaler AVOptions
The Basics edit
FFmpeg is an audio and video transcoder that interfaces with the computer's terminal. This means that if you want to use ffmpeg directly, you must use the terminal. However, you can install a graphical shell if you prefer. See Installing for more information.
At its very basic, FFmpeg decodes 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:
This is a program called FFmpeg, and we're telling it to run from either our environment path or the folder we're in, depending on where you've installed it. The environment path is a system-wide directory that lets you access other commands like
cd from any other location in the system. 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.
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.
Then, we simply tell FFmpeg where to put the new file. In this example, we don't explicitly tell FFmpeg what format to use; 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"
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. See the General section for an explanation.
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.