Two-pass encoding in ffmpeg

I will encode different videos uploaded by user asynchronously on my server. I saw this pos t, and according to that, here's how to encode the xy endcode:

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 to encode the video by simply giving it the -pass 2 flag without the first encoding in the -pass 1 flag. Although I had this warning, it succeeded anyway:

The second pass has more frames than the 1st pass

So my concern is how will ffmpeg know which one is the first pass so it can do its pass 2 encoding? And since many videos will be downloaded at the same time, I cannot store them all in / dev / null if it replaces one with another. So how can I do this?

Your help and guidance would be much appreciated.

Thank.

Upadate

ffmpeg cmd:

ffmpeg -i input.mp4 -codec:v libx264 -tune zerolatency -profile:v main -preset medium -b:v 1500k -maxrate 1500k -bufsize 15000k -s hd720 -threads 0 -pass 1 -an -f mp4 /dev/null

ffmpeg -i input.mp4 -codec:v libx264 -tune zerolatency -profile:v main -preset medium -b:v 1000k -maxrate 1000k -bufsize 10000k -s hd720 -threads 0 -pass 2 -codec:a libfdk_aac -movflags +faststart output.mp4

      

+3


source to share


1 answer


When using 2-pass encoding, the first pass will create files log

using a naming convention ffmpeg2pass-X

where X

is the stream number.

You can use the option -passlogfile

to set a custom prefix for your files. Example:

-passlogfile your_unique_video_id



This will create a file named your_unique_video_id-0.log

for stream 0.

Link to documents

+8


source







All Articles