Search code examples
javascriptffmpegterminalgraphicsmagick

Piping FFMPEG into Graphics Magick


I need to pull something like this off:

foo.user$ ffmpeg -i -y foo.mediafile -ss 0 -vframes 1 -an out.jpg | gm identify out.jpg

Basically, it will need to make a thumbnail of a video frame or still image using ffmpeg and then run gm on it. How can I directly pipe the thumbnail(or not so thumbnail, it needs to be the same size) into gm without having to write to out.jpg. Anyone familiar with ffmpeg piping/gm could you give me a hand? -Thanks!!

P.S. if it helps, this process is being run from server side Javascript.


Solution

  • Answered it myself:

    ffmpeg -i test.jpg -f mjpeg -ss 0 -vframes 1 -an - 2>/dev/null | gm identify -ping -verbose -
    

    This works to take test.jpg (or some other file, .ogv, .png, etc) and process it with ffmpeg and then run it into gm. The important bit is the dashes, they act as anonymous pipe outputs. Also important is the -f mjpeg, to force the pipe into jpeg format. Finally, 2>/dev/null silences the first command.