Just leaving this here for posterity if someone runs into the same issue:
I was for some reason unable to do a 2-pass encoding with AV1.
This is just experimentation for now so I’m using libaom-av1 (which I know is not the most efficient but that’s not the point).
I was doing this, fairly straight forward:
file="S08E01 - Twenty Vicodin.mkv" && \
dir="/mnt/tank/media/_unsorted_stuff/tvshows" && \
ffmpeg -i "${file}" -c:v libaom-av1 -crf 18 -pass 1 -an -sn -f null /dev/null && \
ffmpeg -i "${file}" -c:v libaom-av1 -crf 18 -pass 2 -map 0 -map_chapters 0 -map_metadata 0 -c:a copy -c:s copy "${dir}/${file}"
It did the first pass, created the ffmpeg2pass-0.log file, but then failed on the second pass:
Error opening file ffmpeg2pass-6.log.
[vost#0:6/libaom-av1 @ 0x55ec304b5b80] Error reading log file 'ffmpeg2pass-6.log' for pass-2 encoding
Error opening output file /mnt/tank/media/_unsorted_stuff/tvshows/S08E01 - Twenty Vicodin.mkv.
Error opening output files: Input/output error
✘
Why is it trying to open a -6.log file?
The number is determined by ffmpeg itself so I can’t actually influence that… -passlogfile allows setting the prefix, but the number is automatic.
I tested on 2 separate installs (Fedora in Docker and my Fedora Desktop) to make sure it’s not some environment variable weirdness, but the issue was the same.
I was trying around for a good hour until it hit me (because it’s not mentioned in the Docs I could find):
The number on the log file is the index of the video track in the file. My files were ripped with MakeMKV and my track selection embeds a thumbnail into the video file, which happens to be track 6 in this file:
$ ffprobe "S08E01 - Twenty Vicodin.mkv" |& grep "Stream #0:"
Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn
Stream #0:1(eng): Audio: dts (dca) (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s (default) (original)
Stream #0:2(ger): Audio: dts (dca) (DTS), 48000 Hz, 5.1(side), fltp, 768 kb/s
Stream #0:3(eng): Subtitle: hdmv_pgs_subtitle (pgssub), 1920x1080 (original)
Stream #0:4(ger): Subtitle: hdmv_pgs_subtitle (pgssub), 1920x1080
Stream #0:5(ger): Subtitle: hdmv_pgs_subtitle (pgssub) (forced)
Stream #0:6: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 640x360 [SAR 72:72 DAR 16:9], 90k tbr, 90k tbn (attached pic)
The solution is to specify the codec for 0 and 6 separately:
file="S08E01 - Twenty Vicodin.mkv" && \
dir="/mnt/tank/media/_unsorted_stuff/tvshows" && \
ffmpeg -i "${file}" -c:v:0 libaom-av1 -crf 18 -c:v:1 copy -pass 1 -passlogfile "${dir}/${file}" -an -sn -f null /dev/null && \
ffmpeg -i "${file}" -c:v:0 libaom-av1 -crf 18 -c:v:1 copy -pass 2 -passlogfile "${dir}/${file}" -map 0 -map_chapters 0 -map_metadata 0 -c:a copy -c:s copy "${dir}/${file}"
I’m using c:v:1 because the thumbnail is not always Stream 6, but it is always video stream 2 (and therefore index 1).