Progressively write out each image in a sequence?

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
Jugdizh

Progressively write out each image in a sequence?

Post by Jugdizh »

I'm trying to do some on-the-fly conversion of images before generating a video from them, using a combination of convert and ffmpeg. The input images are in EXR format, which convert can read but ffmpeg can't. So I'm using the PPM format as an intermediary between the two.

Here's my command-line call:

convert 'input.*.exr' -depth 8 ppm:- | ffmpeg -f image2pipe -vcodec ppm -i - -f mov -vcodec libx264 output.mov

This works great except for one issue: the ffmpeg command does not begin encoding the video until convert has finished writing out *every* image. How can I get convert to progressively write out each image in the sequence rather than holding onto them and writing them out all at once?

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Progressively write out each image in a sequence?

Post by fmw42 »

you could use a (shell) script and a loop (while, for, etc) and access and process each image separately from a variable list of images or from a file list of images.
Jugdizh

Re: Progressively write out each image in a sequence?

Post by Jugdizh »

If I convert each image separately in a loop then I would no longer be able to have one pipe open to ffmpeg the whole time. I would have to save out each image onto disk and then run ffmpeg on the files, which would take even longer than my current method. What I'm trying to achieve is convert and ffmpeg running simultaneously, with convert feeding ffmpeg the image data as ffmpeg is encoding the video.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Progressively write out each image in a sequence?

Post by anthony »

I do not think it is "convert" but the pipeline buffering that happens between the commands.
That is convert is writing into a 'in-memory buffer' (the pipeline) which 'ffmpeg' will be reading from when it runs.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply