[FFmpeg-user] stopping ffmpeg correctly while piping

Dave Rice dave at dericed.com
Thu Jan 11 16:25:53 EET 2018

Hi all,
With ffmpeg I’m trying to write a file from a device input while also piping out audiovisual data to a separate player. These commands replicate what I’m trying to do:

ffmpeg -f lavfi -i testsrc will_this_file_work.mov -f nut - | mpv -
ffmpeg -f lavfi -i testsrc will_this_file_work.mov -f nut - | ffplay -

When running these commands the video plays (in either ffplay or mpv). When I close the playback window to stop the player, then ffmpeg also stops, but with an invalid output. In this case the file will_this_file_work.mov will have no moov atom. Any suggestions on how to end this so that I can close the player to stop the process and have a valid file.

I notice that this works:

ffmpeg -f lavfi -i testsrc -f nut - | tee >(ffplay -) | ffmpeg -i - this_does_work.mov

but this requires two instances of ffmpeg.
Dave Rice

More information about the ffmpeg-user mailing list