FFmpeg steals input

I had a shell wrapper script to convert MTS files with FFmpeg, but somehow, when running on multiple files, only the very first one got converted.

Turns out that FFmpeg swallows the stdin from the bash script when it is run and therefore nothing remains in the stdin for the next iterations. To remedy this, I had to fake input to ffmpeg:

while read movie
echo "" | ffmpeg -i "$movie" -vcodec copy -acodec copy "$movie".mov

Without the echo command this would’ve ended after first iteration, regardless of the number of files in the input.

BTW, the above command is useful for turning MTS files into MOV files, while preserving the audio-video streams, for software that does not support MTS.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s