FFMPEG An Intermediate Guide
FFmpeg is a powerful video encoding package. It works with a large number of formats and on most platforms. Unfortunately the documentation can be scary for the beginner.
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 published under the GNU Lesser General Public License 2.1+ or GNU General Public License 2+.
This book guides you through the basics of using FFmpeg. It includes best practices, defines concepts and includes problem solving.
Feel free to help develop this book.
- Basic Transcoding
- Installing FFmpeg and GUI's
- Main options
- Advanced options
- Video options
- Advanced Video options
- Audio options
- Advanced Audio options
- Subtitle options
- Audio/Video grab options
- AVCodecContext AVOptions
- AVFormatContext AVOptions
- SWScaler AVOptions
Get started with FFMPEG transcoding
FFmpeg is a command line video transcode/encoder. You need to be in your systems command line to use it or you need to install a Graphic User Interface. For more information look at the Installation section.
To run a basic FFmpeg transcode type the following command, input_video, and output_video with your chosen files.
ffmpeg -i "input_video.mpg" "output_video.mov"
Taking this line one piece at a time:
Runs the ffmpeg programme. If you receive a message along the lines of "Programme not found", you either need to run the command in the same folder as ffmpeg.exe or to read up on specific instructions for you system.
Input: Your input video should follow this command. Note! File extensions are essential in the command line.
The name of the output video file that you intend to create. The extension (in this case .mov) defines the kind of video file. As this is the simplest of FFmpeg commands it assumes that you want the most generic output file of the type defined by the extension. Unfortunately I find that you need to make one or two tweaks before you get the video file that you actually want.
Putting your video files names in Quotation Marks is not normally necessary but it does help if there are special characters in your file name, especially spaces. FFmpeg expects a new command or setting after a space.
ffmpeg -i "input_video.mpg" -b 3000k "output_video.mov"
Video Bit Rate: This defines in bit per second the quality of video written to the new file. This should dramatically improve you video quality or file size depending on how large the number is that follows the -b. The k at the end of the number indicates that the number is in kilobytes. There is a more in-depth explanation later in the documentation.
Now that you can create a basic video file in FFmpeg, read the basics. Alternatively read more in depth sections if you already understand the basics.
A common question is, "I need a video format that will work on any stock system, Windows, Apple or Linux. What format should I use?" Unfortunately there is only one answer to this question, MPEG1. The answer is less than ideal. Due to copyrights and development issues, it is the only one that has been incorporated into most operating systems, though even it is not present on some light operating systems such as mobile phones. Although it is a great universal format, it is old and simply doesn't compete for quality or size with newer formats.
The Best Format...
Another common question is, "What is the best format?". It is next to impossible to answer. It depends completely on what you intend to do with the video. Editors, colorists or internet viewers need completely different thing. Colorists needs the highest colour quality and video size to work with. Editors need quality but speed is important too, not to mention the ability to play footage backwards frame by frame. End uses watching streaming footage online, want small, clear video. All this need to be taken into consideration before you encode your video.
If pushed I would select the h.264 codec as the most advanced with the largest variety of uses from 4:4:4 to streaming video. It most likely will be the next most incorporated format as everything from blu-ray players, mp4, flash to mov have the ability to store and play back h.264 encoded video. Most operating systems have a free play that will play these back, although again light OS such as cellular phones may not. Even that is changing.
When it comes to container formats, again if pushed, I would say .mov. It is the most widely supported and can be pulled in to most editing packages.
Although these have improved by leaps and bounds in recent years, they are still not as widely integrated, especially in the professional environment. I hope this will soon change. For now think carefully of your intended end users before picking one of the open formats.