[FFmpeg-user] Understanding two pass encoding

Moritz Barsnick barsnick at gmx.net
Sun Aug 9 00:44:56 CEST 2015


On Sat, Aug 08, 2015 at 18:16:13 +0530, Robin Lery wrote:
> Yes, thank you. I understand now. However I tried doing two pass multiple
> output with one input like this:
> 
> ffmpeg -i mi6.mp4 \
>     -codec:v libx264 -tune zerolatency -profile:v main -preset medium -b:v
> 1000k -maxrate 1000k -bufsize 10000k -s hd720 -threads 0 -pix_fmt yuv420p
> -pass 1 -passlogfile unique_id-hd720 -an -f mp4 /dev/null \
>     -codec:v libx264 -tune zerolatency -profile:v baseline -level 3.0
> -preset medium -b:v 250k -maxrate 250k -bufsize 2500k -vf
> scale="trunc(oh*a/2)*2:360" -threads 0 -pix_fmt yuv420p -movflags
> +faststart -pass 1 -passlogfile unique_id-360 -an -f mp4 /dev/null && \
>     -codec:v libx264 -tune zerolatency -profile:v main -preset medium -b:v
> 1000k -maxrate 1000k -bufsize 10000k -s hd720 -threads 0 -pix_fmt yuv420p
> -pass 2 -passlogfile unique_id-hd720 -codec:a libfdk_aac -movflags
> +faststart output/mi6-poty-720.mp4 \
>     -codec:v libx264 -tune zerolatency -profile:v baseline -level 3.0
> -preset medium -b:v 250k -maxrate 250k -bufsize 2500k -vf
> scale="trunc(oh*a/2)*2:360" -threads 0 -pass 2 -passlogfile unique_id-360
> -codec:a libfdk_aac -pix_fmt yuv420p -movflags +faststart
> output/mi6-poty-360.mp4

No no no! That's _one_ ffmpeg command, right? You're now tring to do
pass 1 and pass 2 in parallel. You're missing the point: ffmpeg _must_
be called twice (i.e. two passes) using the same input file _in
succession_. The first pass creates the log file, the second pass uses
that log file (_after_ it has been created by the first pass) to do the
final encode.

> When I run this command first I get this:
> File '/dev/null' already exists. Overwrite ? [y/N] y
> File '/dev/null' already exists. Overwrite ? [y/N] y

ffmpeg doesn't know that this is a "special" file the contents of which
may be overwritten, so it does ask.

> Afterward there's two file with the specified name, but the file size is 0.
> What's going on?

You mean name_s_. Reason is above: You are not doing two successive
passes.

Moritz


More information about the ffmpeg-user mailing list