Ffmpeg slideshow piping input and output for image stream

ffmpegunix

I am trying to make from a list of images a video and then I will directly upload it.
I have managed so far to create a video for the images with:

cat *.jpg | ffmpeg -r 1 -f image2pipe -vcodec mjpeg -i - foo.mp4

It works well and I'm happy with it. However, now I would like to pipe the output and I can't really manage to do this. I've tried a couple of like:

cat *.jpg | ffmpeg -f image2pipe -r 1/5 -vcodec mjpeg -i - pipe:1 | cat > p.mpeg

(for the moment I would just like to pipe back in a file just to test and then I'll had the direct upload).

I've read in another thread that I should specify the output format which makes sense as the error returned by ffmpeg is "Unable to find a suitable output format for 'pipe:1'". However, all I can find in the doc is:

-f fmt (input/output)
Force input or output file format. The format is normally auto detected 
for input files and guessed from the file extension for output files, 
so this option is not needed in most cases.

How can I specify the output format and the input format?

Best Answer

You need to explicitly set some output format. Which one doesn't really matter, but after -i, you need:

  • a -c:v copy to just copy the JPEG stream
  • a -f format
  • - as the output pipe

From my experience matroska works fine as an output format.

cat *.jpg | ffmpeg -f image2pipe -r 1/5 -c:v mjpeg -i - -c:v copy -f matroska - | ffplay -

I just tested this and it runs without issues. The file plays in VLC as well when you do | cat > out.mkv instead of the ffplay call.

Related Question