I’m encoding videos from a background process and found a video where
the audio sync is off … but only when the encoder is run inside a
daemon. After some work boiling down the Daemons code, I was able to
reduce the entire problem down to this:
I haven’t simplified the ffmpeg command itself because eventually I
began using the resulting file size to indicate the problem. When line 4
is commented out and the audio syncs correctly, the file size is about
7400 bytes larger.
What I don’t understand is how STDIN.reopen could have any effect on the
ffmpeg command. I tried directing the first-pass ffmpeg output to a
standard file instead of /dev/null, but it made no difference. I also
tried changing STDIN.reopen to a temporary file … no difference.
Could anyone with deeper knowledge shed some light on the problem, or
suggest further tests?