[FFmpeg-user] Error ‘can’t open stats file’ using 2 pass encoding with multiple audio inputs

Carl Eugen Hoyos ceffmpeg at gmail.com
Sat Mar 14 22:06:20 EET 2020


Am Sa., 14. März 2020 um 20:09 Uhr schrieb Jeff Langston <jrlangston at gmail.com>:
>
> Hi,
>
> Here's the input commands boiled down to the simplest reproducible
> versions.
>
> Here's links to the input files https://s3.amazonaws.com/Jlangston/bunny.mp4
> https://s3.amazonaws.com/Jlangston/track1.m4a
> Trying either without the 2nd audio input or without rendering multiple
> video versions with multiple audio tracks seems to work but the combination
> of multiple input audio tracks and multiple output versions is hitting.
> Which I am guessing might be around the usage of the -passlogfile option.
>
> [libx264 @ 0x5562fa469c80] ratecontrol_init: can't open stats file
> Error initializing output stream 0:2 -- Error while opening encoder for
> output stream #0:2 - maybe incorrect parameters such as bit_rate, rate,
> width or height
>
> If I leave out the -passlogfile option I get a message about failure to
> rename log file in pass1.
>
> [libx264 @ 0x5621f1bcdfc0] failed to rename "ffmpeg2pass-0.log.temp" to
> "ffmpeg2pass-0.log"
> [libx264 @ 0x5621f1bcdfc0] failed to rename "ffmpeg2pass-0.log.mbtree.temp"
> to "ffmpeg2pass-0.log.mbtree"
>
> Here's the commands and their outputs below. Thank you in advance for any
> assitance or guidance you might be able to provide as well as everyone's
> work on ffmpeg.
>
> Pass 1:
> ffmpeg \
> -i ./bunny.mp4 \
> -i ./track1.m4a \
> -loglevel debug -v verbose \
> -map 0:a \
> -metadata:s:a:0 language=en \
> -metadata:s:a:0 title=track_one \
> -map 1:a \
> -metadata:s:a:1 language=ch \
> -metadata:s:a:1 title=track_two \
> -f dash \
> -map 0:v:0 \
> -s:v:0 1920x1080 \
> -b:v:0 1460k \
> -passlogfile:0 1080p \
> -map 0:v:0 \
> -b:v:1 683k \
> -s:v:1 1280x720 \
> -passlogfile:1 720p \
> -c:v libx264 \
> -profile:v baseline \
> -movflags faststart \
> -r 30 \
> -seg_duration 4 \
> -single_file 1 \
> -hls_playlist 1 \
> -streaming 1 \
> -dash_segment_type mp4 \
> -pass 1 \
> -an \
> -f mp4 /dev/null
>
> Pass 2:
> ffmpeg -y \
> -i ./bunny.mp4 \
> -i ./track1.m4a \
> -loglevel debug -v verbose \
> -map 0:a \
> -metadata:s:a:0 language=en \
> -metadata:s:a:0 title=track_two \
> -map 1:a \
> -metadata:s:a:1 language=ch \
> -metadata:s:a:1 title=track_one \
> -f dash \
> -map 0:v:0 \
> -s:v:0 1920x1080 \
> -b:v:0 1460k \
> -passlogfile:0 1080p \
> -map 0:v:0 \
> -b:v:1 683k \
> -s:v:1 1280x720 \
> -passlogfile:1 720p \
> -profile:v baseline \
> -movflags faststart \
> -r 30 \
> -seg_duration 4 \
> -single_file 1 \
> -hls_playlist 1 \
> -streaming 1 \
> -dash_segment_type mp4 \
> -pass 2 ./out/out.mpd

I don't know if this is the issue here (or if dash simply doesn't
forward the passlogfile
name to x264) but in general you cannot do this, you have to use the same output
format and especially the same audio for pass one and two. The reason is that
ffmpeg (the application) may duplicate (or drop) frames to keep a/v sync and if
you use different audio (like audio and no audio) for pass one and
two, the different
sync will completely brake two-pass encoding.

The problem gets worse by the fact that in general, neither ffmpeg nor x264 can
detect that you are using different settings for the two passes (x264 sometimes
crashes if the passes do not fit, I always wondered if this isn't a good thing).

Carl Eugen


More information about the ffmpeg-user mailing list