Search code examples
ffmpegwindows-10imagemagick

How to pipe ffmpeg output to ImageMagick's convert tool?


After a lot of searching I have come up with this to pipe a frame from ffmpeg to imagemagick's convert tool.

ffmpeg -y -ss 00:02:01 -i ...\pano.mp4 -frames:v 1 -f png - | convert -sharpen 0x1 ...\pano_00_02_01.png

I keep getting this error message.

[NULL @ 000002e6cd1e00c0] Requested output format 'png' is not a suitable output format
pipe:: Invalid argument

I have checked for png support using ffmpeg -format and its listed as png_pipe.

I'm using ffmpeg version 4.3.1-2020-11-19-full_build https://www.gyan.dev/ffmpeg/builds/


Solution

  • In ffmpeg there is no muxer named png (see ffmpeg -muxers). To pipe a single image replace -f png with -c:v png -f image2:

    ffmpeg -y -ss 00:02:01 -i pano.mp4 -frames:v 1 -c:v png -f image2 - | convert - -sharpen 0x1 pano_00_02_01.png
    
    • If you're doing many iterations of this consider changing -c:v png to -c:v pam as it is faster (no need for compression) and supports most of the same pixel formats.

    • I also added the - as the piped input in the convert command.

    • Originally I suggested -f image2pipe as it should work with a piped single image and a sequence so it would be more flexible for a more general answer. It worked in Linux but in Windows the OP got error av_interleaved_write_frame(): Invalid argument Error writing trailer of pipe:: Invalid argument. I don't know why (not a Windows user).