[FFmpeg-user] Send ffmpeg segments to stdout so they can be processed by next pipe

Mark Filipak (ffmpeg) markfilipak at bog.us
Fri Jan 29 02:02:46 EET 2021


On 01/28/2021 06:30 PM, Szymon Danielczyk wrote:
> I have a pipeline like this in which I simulate a video stream
> 
> ffmpeg -i input.mov -f matroska - |\
> ffmpeg -i - -codec copy -map 0 -reset_timestamps 1 \
> -segment_time 10 -f segment  output/out%03d.mov
> 
> which works and it is splitting the input video into 10 sec long segment files saved into output folder. Now I would like to instead tell ffmpeg to pass them to stdout so in the next pipe I can hook up a script to decide what to do which each segment based on a presence of another file
> 
> ffmpeg -i input.mov -f matroska - |\
> ffmpeg -i - -codec copy -map 0 -reset_timestamps 1 \
> -segment_time 10 -f segment |\
> NEXT_PIPE_SCRIPT
> 
> The NEXT_PIPE_SCRIPT should be something like
> {
> TEST_FILE=".do"
> if [ -f "$TEST_FILE" ]; then
>       echo "$TEST_FILE exists going to redirect videos to a folder"
>      >> output/$RANDOM.mov
>   else
>      >> /dev/null
> fi
> }
> 
> The idea is that depends if the file is there or not some segments should go to /dev/null and some to the output folder.
> After much googling I've found this old thread which sais that writing segmented files to stdout is not supported
> 
> https://ffmpeg.org/pipermail/ffmpeg-user/2017-November/037718.html
> 
> Also I do not see any example in the ffmpeg documentation of outputing segments to stdout.
> 
> If this is true will anyone have an idea how to solve it in some other way?

Would it be possible for ffmpeg to output raw video frames, one file per frame, then the next 
(continuously running) process to pick up the files as they are created, to process them and then 
delete the originals on the fly? Could that be done in a script?


More information about the ffmpeg-user mailing list