FFMPEG / x264: can I use pass 1 from one encoding session as pass 2 for another?

0

Question:

Is it legal to use a "pass 1" encoding of a source video at one resolution/bitrate as the input to a "pass 2" encoding of the same source at a different resolution/bitrate? I tried it and it seeeeeeems to work, but am not at all certain it will in the general case: the stream profile (I/P/B frame choice, etc.) looks different from using the same parameters for both passes, but also looks "good enough".

I am at the point where I need an authoritative answer on this one.

Why in tarnation 1 would you do that?

Because two-pass encoding fixes a maddening bug in FFMPEG (x264, really) that probably won't get fixed any time soon: depending on the speed of your machine, the first ~1 second or so of video will often have a highly inappropriate bitrate. This is very easily reproduced with a high bitrate source stream transcoded to a low bitrate on a very fast machine (such as an EC2 c4.8xlarge). An idle i7 quadcore MacBook Pro IS NOT sufficient to reproduce this bug.

It will either be EXCEEDINGLY high:

  • single pass CBR with no VBV specified

    (ignore the fact that CBR without a VBV isn't CBR at all)

or too low:

  • single pass CBR with VBV
  • single pass VBR: QScale with VBV and maxrate

Both VIFp and SSIM quality measurements show that the lower/high bitrates do indeed correspond to unnecessarily reduced/increased quality (i.e. the bitrate should NOT have been higher or lower).

Doing a two-pass CBR encoding works great and solves the problem...if you have the time for it. Unfortunately, I can't afford the latency of a two-pass encoding for a single resolution.

So what is it you want to do?

I am currently performing an initial transcode at a lower resolution (480). This will cover as many playback devices as possible. I would like to use that as my pass 1. Since 480 resolution sucks anyway, I can just post that pass 1 video as my 480, regardless of any silly bitrates in the first second of video.

I would then like to use the 480 pass 1 info and only do pass 2 on my higher resolutions. In the CBR/VBV case, this would be:

ffmpeg -i source.mp4 -pass 1 -vf  scale=852:480 -c:v libx264 -b:v 1000k ... 480.mp4
ffmpeg -i source.mp4 -pass 2 -vf scale=1280:720 -c:v libx264 -b:v 2500k ... 720.mp4

Barney Google

Mark Gerolimatos

Posted 2015-09-16T22:22:20.943

Reputation: 1 089

Can you please post the complete FFmpeg log ? I have a feeling your encodes use too many threads considering those low resolutions, which is detrimental to the quality. – Ely – 2015-09-16T23:34:00.250

What bug are you referring to? – llogan – 2015-09-16T23:51:01.033

Please see this link: http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6652

– Mark Gerolimatos – 2015-09-17T04:33:53.513

@Ely Hi, Ely! It's me, Mark! I am still not convinced that this is a thread issue, or perhaps are convinced that the too many thread issue is a red herring in that it merely enables the bug. Remember that at a high bitrate, I need a BUNCH of threads and very fast machines to ensure timely transcoding. – Mark Gerolimatos – 2015-09-17T17:38:37.733

@LordNeckbeard (redone to give you an "at"/notification). Here's the URL that Ely and I had a discussion on: http://ffmpeg.gusari.org/viewtopic.php?f=11&t=2296&p=6652

– Mark Gerolimatos – 2015-09-17T17:39:40.193

No answers