pipe ffmpeg output to magick

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mhansen49
Posts: 2
Joined: 2019-01-25T08:24:10-07:00
Authentication code: 1152

pipe ffmpeg output to magick

Post by mhansen49 »

Is there a way to pipe output files from FFPEG directly into MAGICK CONVERT?
I want to take the output frames then average them without making hundreds of intermediate files.
(working on a PC)

This example fails ERROR MESSAGE: Unable to find a suitable output format for 'pipe:1'
ffmpeg -i MDI_3434.avi -vf fps=1 pipe:1 | magick convert - -average test3.png

Thanks for your help
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pipe ffmpeg output to magick

Post by snibgo »

"-average" is deprecated. You should use "-evaluate-sequence mean". For example:

Code: Select all

ffmpeg  -r 1 -i 2.avi -r 1 -c:v pam -f image2pipe pipe:1 | magick - -evaluate-sequence mean x1_%06d.png
snibgo's IM pages: im.snibgo.com
mhansen49
Posts: 2
Joined: 2019-01-25T08:24:10-07:00
Authentication code: 1152

Re: pipe ffmpeg output to magick

Post by mhansen49 »

The suggested code only pipes the first image. I need to pipe all images in order to compute the mean.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: pipe ffmpeg output to magick

Post by snibgo »

I get all the frames. To demonstrate this, insert "+write info:" after the "-" for magick's input:

Code: Select all

ffmpeg  -r 1 -i 2.avi -r 1 -c:v pam -f image2pipe pipe:1 | magick - +write info: -evaluate-sequence mean x1_%06d.png
This creates text output from magick that starts:

Code: Select all

-[0] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.016
-[1] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.031
-[2] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.031
-[3] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.047
-[4] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.062
-[5] PAM 960x540 960x540+0+0 8-bit TrueColor sRGB 0.016u 0:00.062
The result of "-evaluate-sequence mean" is only one image, of course. If you remove "-evaluate-sequence mean" you will get all frames as PNG files.
snibgo's IM pages: im.snibgo.com
Post Reply