#533 Optional 2pass mode / cfr-2pass-combi mode


Sorry for the strange title, it's a bit hard do discribe with just a few words.

Is it possible to add a mode, that is a combination between constant quality and bitrate mode? What I mean is a mode, where you define a crf value and a maximum bitrate. The first pass will be done with a crf value, slow firstpass activated and the video output will be kept. If the overall bitrate of the output video exceeds the defined max bitrate, there will be a second pass, otherwise pass 2 will be skipped.
I know this can be done manually, but an option that would automize this would be great.

Here's a pseudo code that might explain what I'm talking about:


//pass 1:
x264 --pass 1 --slow-firstpass --crf $CRF --stats ".stats" --output $OUTPUT $INPUT

//pass 2:
IF bitrate($OUTPUT) <= $MAX_BITRATE {
do nothing
} ELSE {
delete $OUTPUT
x264 --pass 2 --bitrate $MAX_BITRATE --stats ".stats" --output $OUTPUT $INPUT

Let's assume you want to use the same encoding options on all your video game footage, this way high motion stuff (i.e. action games) will likely be encoded in 2 pass mode, while the second pass will automatically be omitted for low motion stuff (i.e. point-n-click adventures).


  • De-M-oN

    De-M-oN - 2014-01-19

    hmm could be useful.

    And it seems to me that youtube does exactly this to all qualities up to 1080p. The qualities above 1080p are other handled though. But youtube uses not CRF, rather a quantizer. But the behaviour you describe I can see at youtubes coding how said as well.
    For example youtubes 1080p has a maximum of 4000 kbit but videos like tutorials etc wont get the 4000. So they basically do what you describe as well.

    So it should be somehow possible at least.

  • De-M-oN

    De-M-oN - 2014-01-31

    works by using vbv-maxrate and vbv-bufsize
    vbv alone doesnt work as I've seen on a other website.
    so you have to use it with buffer together. If no hardwareplayer set the buffer to the highest possible value and the vbv-maxrate to your desired maximum bitrate.

    Remember that CRF is a 1pass encode. So if you define a 6000 kbit maxrate and the video needs it fully with your wanted CRF, then a bitrate based encode at 2pass with this 6000 bitrate may/will look better.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks