[FFmpeg-user] Understanding two pass encoding

Robin Lery robinlery at gmail.com
Thu Aug 6 16:12:39 CEST 2015

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?

Your help and guidance will be very much appreciated.

Thank you.

More information about the ffmpeg-user mailing list