I know that it's very hard to find out best encoding parameters for a whole video file. Wouldn't it be easier to just go through the video and find out the best parameters for different parts (or scenes).

Does it make sense or probably there is software that already allows that?

  • 1
    No need to use two-passes. See the FFmpeg and x264 Encoding Guide; specifically the section on using a constant rate factor (CRF) for examples and more information. All you need to do is pick your crf value which controls your quality, and your encoding preset which controls your encoding speed/compression efficiency.
    – llogan
    Mar 15, 2013 at 21:34

3 Answers 3


What you are describing is effectively what 2-pass VBR does for you. It makes a first path that calculates the level of change for each particular time in the video and then uses this information to make the best possible use of the available storage space.

It is, however, entirely possible to do the process manually by doing multiple encodings with different parameters. In fact, many formats even support having multiple encodings with different parameters within the same file. This is how you are able to change the resolution on the fly when streaming videos on YouTube and how Netflix automatically adjusts the quality on the fly as you watch to try to avoid buffering issues.

Any professional level encoder should allow you to specify multiple formats for the file in queue and many will even let you specify multiple outputs for one instance of the file. (For example, the render queue in After Effects allows for this.)

In general, I would recommend running a 2-pass VBR and then adjusting the keyframe and total bandwidth accordingly. If you are using a format that works based on the motion in the scene, then generally keyframes need to be more often if the video gets lots of motion artifacts (where it diverges from where it actually should be too much in high motion). If the video is simply too low quality and "pixelly", then the bandwidth generally needs to be raised or the keyframes lowered.

  • Do you know of software that allows scene/regional parameters for MPEG-2 or AVC encoding? I have read that Hollywood DVDs are mastered by a 'compressionist' who uses tools which allow such fine-grained tweaking.
    – Gyan
    Mar 22, 2013 at 9:45
  • @Mulvya - I have used such a package once when I was using a hardware encoder and Sonic DVD Producer for MPEG-2. The software was however very complex, unstable and unwieldy and was, in short, the largest waste of $5 grand I have ever spent. There may be cheaper options that allow that level of control now, but unless you are thoroughly knowledgeable about the algorithms and looking through for particular artifact problems, you will probably have better luck with 2 pass VBR.
    – AJ Henderson
    Mar 22, 2013 at 13:12

Yes, some encoders allow changing parameters (like target quality or bitrate, or psychovisual tuning options (x264's aq and psy-rd options).

x264, the stand-alone command-line frontend for the library, has a --zones parameter to give more bitrate to some parts of the video. So you could for example reduce the quality for the credits.

The actual x264 library supports changing many parameters on the fly, but I don't know if ffmpeg has a way to specify option changes for ranges of the video. You could get nearly the same result by segmenting your video, and encoding the different segments with different options, then combining them.

Generally nobody actually does this, because it's a HUGE amount of work, and it's really hard to know which settings are going to help just by looking at a scene. Usually if you want more quality, you just spend more CPU time on the encode, and that improves everything across the board. (--preset veryslow). I could imagine getting some benefit out of tweaking AQ settings, though, maybe to address banding in one scene, but changing it for other scenes where that wasn't an issue.

Still, bits are essentially never precious enough for it to be worth paying a human to save them, instead of just electricity and CPU time. This is more of a hobby thing / thought experiment to see what different codec settings do, IMO. Maybe when we need to stream video to / from a mars colony, bits will be that precious...


Variable bit rate and adaptive codecs are common in the audio world, and work very well. The most obvious example is VBR MP3s. Encoding video is a fundamentally similar problem, so I would be surprised if adaptive codecs don't exist there too.

  • That would be good to know they are exist. However, I wonder if there are semi-automatic applications for professionals who wish to adjust quality of the output to the best.
    – Kentzo
    Mar 14, 2013 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.