I've seen a number of 2-pass encode examples and they often use the -an switch on the first pass. This seems to be because on the first pass only video data is sampled for the log file used by the second pass to create a more efficient encoding. I noticed this switch again when answering this question and I'm wondering if there is any effect whatsoever in using this switch on the first pass of a 2 pass encode.
1 Answer
Any effect at all?
Yes. Using the -an switch causes ffmpeg to skip processing the audio stream.
Any positive benefit?
Yes there is a measurable decrease in processing time.. I took a 60 second mp4 source clip to use for testing and issued the command
time ffmpeg -i input.mp4 -y -an -c:v libvpx -quality best -b:v 225k -qmin 10 -qmax 42 -maxrate 300k -bufsize 1000k -threads 4 -pass 1 -f webm /dev/null
I obtained the following output:
frame= 1799 fps=174 q=0.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknownOutput file is empty, nothing was encoded
real 0m10.477s
user 0m12.972s
sys 0m0.188sand then renamed the resulting log file an.log for comparison later.
I ran the command again without the -an switch as in
time ffmpeg -i input.mp4 -y -c:v libvpx -quality best -b:v 225k -qmin 10 -qmax 42 -maxrate 300k -bufsize 1000k -threads 4 -pass 1 -f webm /dev/null
The resulting output was:
frame= 1799 fps=165 q=0.0 Lsize= 505kB time=00:01:00.01 bitrate= 68.9kbits/s
video:0kB audio:483kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 4.367473% real 0m11.088s user 0m13.792s sys 0m0.156sSo it looks like it's a little bit faster to run the first pass with the -an
Any change to the 1st pass log file?No. As expected the log files are identical as running diff on them proves.