2pass encoding by ffmpeg at once
Instead of running these as 2 separate commands you can run them on one command line like so:
$ ffmpeg -i input.avi -pass 1 -an output.mp4 && \
ffmpeg -i input.avi -pass 2 -ab 128k -y output.mp4
The difference is the &&
notation which will run the second command (the 2nd pass) only if the first command was successful. They're still 2 separate operations, but this will allow you to run one command line vs. the 2 you were having to do previously.
Also this will have the benefit of running the 2nd pass immediately upon completion of the 1st pass, where with your way you'd have to essentially wait for the 1st to finish before kicking off the 2nd.
Related videos on Youtube

ironsand
Updated on September 18, 2022Comments
-
ironsand 3 months
I encode a video file by using ffmpeg like this.
$ ffmpeg -i input.avi -pass 1 -an output.mp4 $ ffmpeg -i input.avi -pass 2 -ab 128k -y output.mp4
So I typing always 2 times, is there way to encode a video by 2-pass at once?
I change a options often and of course input and output file name is different each times.
-
Ignacio Vazquez-Abrams about 9 yearsYou want to do a 2-pass encoding in one pass?
-
frostschutz about 9 yearsIf you don't have constraints regarding file size (i.e. must fit optical media), consider using CRF instead of 2-pass.
-
ironsand about 9 yearsI don't know which one is better, but IMHO 2-pass encoding is better if bitrate is same. So I prefer to use 2-pass.
-
-
JamesTheAwesomeDude over 7 yearsI wonder if you could do something like
ffmpeg -pass 1 -passlogfile - | ffmpeg -pass 2 -passlogfile -
to encode both passes at once? -
Frank Nocke over 1 year@JamesTheAwesomeDude Piping (
|
) is almost certainly wrong. Either&&
(only continue if no error returned) or;
(2nd command follows, no-matter-what) -
JamesTheAwesomeDude over 1 year@FrankNocke piping would allow better parallelism in this case, if ffmpeg supports it.