Lately i've posted a lot of questions about how to use ffmpeg. It's pretty clear to me that I am missing some sort background in video encoding and was wondering if any of my fellow superusers had any good resources for studying up on video encoding. What do I need to understand before I can use ffmpeg effectively?
Answer
Video formats and general guidelines
First of all, you need to understand which different codecs and formats exist, and what they are typically used for:
What is a Codec (e.g. DivX?), and how does it differ from a File Format (e.g. MPG)?
You should also look into what makes up video quality in a more general fashion, e.g. how does bit rate, frame rate, or picture size affect the quality?
Let's use FFmpeg…
You should know how to install the latest version of FFmpeg. The latest versions always include up-to-date bugfixes and new functions. People often make the mistake to use the old versions bundled with their distributions or that they have on some server – these often just do not work.
Read the FFmpeg documentation, at least the general options, and learn the basic command line switches.
Also check out our Super User blog entry: FFmpeg: The ultimate Video and Audio Manipulation Tool for an always up-to-date guide on transcoding with FFmpeg and a few examples as well as a large link collection at the end.
Encoding with x264
The best free video encoder out there today is x264, and using libx264
, FFmpeg can use it too. You should install x264 and read the help with x264 --fullhelp
. x264 has plenty of options, which are mapped to FFmpeg.
For encoding, you will then be able to use the presets x264 offers. They are accessible through the FFmpeg options too. There are some main options which come in handy. Read the x264 encoding guide on the FFmpeg wiki. In short, this is what you can use:
-profile:v
specifies the h.264 profile to be used, for examplehigh
, which could be used for all kinds of video playing software, orbaseline
, which restricts the video to use features that work on a mobile phone or iPod only.-preset
specifies the encoding presets for speed.fast
will give you faster results, but worse compression, for example. These range fromveryslow
toultrafast
. Default ismedium
.-tune
offers options for tweaking the output based on the input files, e.g. animated movies withanimation
or normal movies withfilm
.-crf
sets the Constant Rate Factor, the #1 method to be used when trying to tweak the result quality. Read up on it here. Use a value between 18 and 27, where lower means better quality. Default is 23.
You can install a video encoder like Handbrake and see which options it uses. Learn by doing, and try to read up on what all the parameters do.
No comments:
Post a Comment