[FFmpeg-user] Simultaneous two-pass?

Gabri Nurtinaz Shally gabri.ns at gmail.com
Thu Sep 27 13:35:20 CEST 2012


On Sep 27, 2012 5:40 PM, "Jesse Gordon" <tojesseg at gmail.com> wrote:
>
> What I mean by borrowing is that when a high action scene comes, it can
encode a few frames above the stated bit rate. This action, however,
borrows from the bitrate budget (and the player's buffer.)
>
> However it can only borrow from the budget if it knows that the next few
frames are lower in action, thereby allowing it to pay back quickly what it
borrowed from the bitrate budget.
>
> Some slow frames in the next second of video allow us to over-spend in
this second.
> However, if the first second of slow video is in 10 minutes, we can't
overspend now because we need to pay it back before 10 minutes.
>
> Does that make sense, or am I all confused? (The latter is possible and I
don't mind someone pointing it out!)
>

lets make an example to point out how important it is two pass feature to
encode efficienly. well, i never read the encoder so maybe algorithm i came
up with will wrong.

lets take a video with altering slow|fast|slow|fast|slow and we want a
bitrate 700kbps.
the first part will be encoded at 700kbps with q=5.
the second part the encoder can't cope with the previous quantizer and has
to lower it to q=15, bitrate still 700kbps.
the third part, the encoder will try to rise the quantizer to q=13, and
there will be an excessive bitrate 300kbps.
this excessive bitrate will be used in fourth part, with q=13 and bitrate
1000kbps.
on the last part, once again the encoder will try to rise the quantizer to
12 and there will be excessive bitrate 200kbps. but will never be used
since it the last part of the video.

as you can see, there is variation in quantizer, that will also affect
variation in quality. plus there will be excessive bitrate at the and.

using two pass encoding, the encoder will know, which part that need high
bitrate, and which part that need.

btw, if you care so much about bitrate that required for streaming, it is
better to use single pass and vbmax set same with bitrate, so the video
bitrate will never excess it intendes to. the video filesize may will be
smaller since excessive bitrate from slow part will never be used.


More information about the ffmpeg-user mailing list