[FFmpeg-user] Simultaneous two-pass?

Jesse Gordon tojesseg at gmail.com
Thu Sep 27 10:06:51 CEST 2012


On 09/27/2012 12:29 AM, Gabri Nurtinaz Shally wrote:
> the purpose of doing the encoding two times is so the encoder can get 
> the statistik of video, knowing which part is a high motion that need 
> higher bitrate, or which part that slow motion that can be given 
> little bitrate. by knowing this, the encoder can distribute bitrate 
> efficienly. so, doing the first and second pass at the same time is 
> basicly defeat the purpose of two pass encoding. 
I realize pass 2 must run some number of frames after pass 1 -- but how 
many frames? Surely pass 2 could start encoding happily if pass 1 was 10 
seconds of video ahead. I can't believe that pass 2 needs the log for 
the very last frame before it can encode the first frame :-)

Well, I guess if a 1mbit video had 5 minutes of high motion then 5 
minutes of no motion, it could actually encode the first 5 minutes at 
almost 2mbit, and it would need to know about the entire video before 
encoding the first frame.

Of course if the video had 1 minute of high action and 9 minutes of low 
action, it could encode that first minute at almost 10mbit, and the rest 
at almost nothing :-)

But I suppose there is a limit to how far ahead bandwidth can be 
borrowed. All I want is to run the second pass just one 
borrow-window's-width behind the first pass :-)

But it's OK. I'll see if I can just write some scripts to run multiple 
conversions simultaneously because when a user uploads a video it does 
convert it to half a dozen different bitrate/resolutions to be suitable 
for viewing on different internet connection speeds. -- so I can just 
get several of those going in parallel to speed things up.

(I should also probably make my converter spider script to run ffmpeg as 
nobody and pipe the data to/from it rather than running it as a user 
with write permission, so that if someone uploads a video that somehow 
buffer overflows ffmpeg it'll be less likely to be able to modify any 
files.)

>> I have more then one CPU so running both passes somewhat concurrently would be meaningful.
> don't worry, modern encoder now support multithreading. all your cpu
> resource will be used entirely b^-^

I just used git clone on the dev branch to download, compile and install 
so I must have the latest.

I have 8 cores in my CPU and I did notice that ffmpeg was using about 
"160%" which means almost 2 cores. However, idle was still around 80%, 
and disk IO was very low.  I have 16G of ram and no swapping is going on.

Should a single ffmpeg instance really peg all 8 CPUs? I'd be happy if 
it did, but it doesn't seem to :)

Thanks very much,

~Jesse






More information about the ffmpeg-user mailing list