[FFmpeg-user] Understanding two pass encoding

Francois Visagie francois.visagie at gmail.com
Thu Aug 6 16:21:04 CEST 2015

> -----Original Message-----
> From: ffmpeg-user [mailto:ffmpeg-user-bounces at ffmpeg.org] On Behalf Of
> Robin Lery
> Sent: 06 August 2015 16:13
> To: ffmpeg-user at ffmpeg.org
> Subject: [FFmpeg-user] Understanding two pass encoding
> I will be encoding different videos uploaded by the user asynchronously in
> my server. I saw this post, and according to this, this is how to endcode two
> pass encoding:
> ffmpeg -y -i input -c:v libx264 -preset medium -b:v 555k -pass 1 -c:a
> libfdk_aac -b:a 128k -f mp4 /dev/null && \
> ffmpeg -i input -c:v libx264 -preset medium -b:v 555k -pass 2 -c:a libfdk_aac -
> b:a 128k output.mp4
> I noticed the -pass 1 and -pass 2 flags. But I tried encoding a video by just
> giving it a -pass 2 flag without first encoding in -pass 1 flag.
> Although I had this warning, it executed anyway:
> 2nd pass has more frames than 1st pass
> So, my concern is how will ffmpeg know which one is the first pass so that it
> can do its pass 2 encoding? And since many videos will be uploaded
> simultaneously I can't keep them all at the /dev/null as it will replace one
> with another. So how can I manage it?

Consider using

‘-passlogfile[:stream_specifier] prefix (output,per-stream)’

    Set two-pass log file name prefix to prefix, the default file name prefix is “ffmpeg2pass”. The complete file name will be ‘PREFIX-N.log’, where N is a number specific to the output stream

> Your help and guidance will be very much appreciated.
> Thank you.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user

More information about the ffmpeg-user mailing list