distinct single images from a input pipeline

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
maweber
Posts: 2
Joined: 2018-05-28T16:29:52-07:00
Authentication code: 1152

distinct single images from a input pipeline

Post by maweber »

I'm trying to extend ffmpeg's ability to output image sequences with IM,
by piping a stream of multiple ppm from FF to IM without buffering everything.

In this thread, at the end:
http://www.imagemagick.org/discourse-se ... hp?t=18320

anthony says:
IMv7 will have features to read a single image from a input pipeline, rather than reading the whole pipeline all at once.
This means you should be able to loop over a "magick" (IMv7 version of convert) command which reads and processes each image in a pipeline before passing it on.
Is this distinction of single images from a pipe implemented yet?
if so, can somebody give a few keywords for the settings (or is it automatic)?

thank you very much
best wishes
manu

ps: I'm on ubuntu16 and I think I have a long way compiling IM with the full tiff extension, so I'm glad for the information in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: distinct single images from a input pipeline

Post by fmw42 »

This is the porting document. If what you are looking for is not there, then the developers will have to comment further. See http://imagemagick.org/script/porting.php#cli
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: distinct single images from a input pipeline

Post by snibgo »

maweber wrote:Is this distinction of single images from a pipe implemented yet?
If I understand what you are asking, "mogrify" does that. For example:

Code: Select all

f:\web\im>%IMG7%magick rose: logo: miff:- |%IMG7%magick mogrify -resize 50% -write x.png -
The result is x-0.png and x-1.png, resized versions of the inputs.

Note that "mogrify" doesn't have the full power of a general "magick" command, and may not execute its commands in the same order they are given.
snibgo's IM pages: im.snibgo.com
maweber
Posts: 2
Joined: 2018-05-28T16:29:52-07:00
Authentication code: 1152

Re: distinct single images from a input pipeline

Post by maweber »

thanks for your suggestions.
the changelog/port page does not reveal the answer to me, AFAI can tell.

to clarify: this command

Code: Select all

ffmpeg -i $input -an -c:v ppm -f image2pipe - | convert - tif:/media/path/testout%04d.tif
does not work for large chunks of image streams, because everything is buffered into the IM6 temp dir (and if that temp dir is a tmpfs, it will run out of space sooner or later, slowing down the process too). it seems IM6 waits for the whole ffmpeg command to be completed in order to start working on all the images.

instead what I am asking is, if IM7 does manage to know when a single ppm is transmitted, and do that image right away, keeping the pipe going, and not buffering more than is needed.

it seems to me the proposal of mogrify is because it can do an output naming of "do not replace, create numbered copy"? But convert does handle this with the "%04d" filename syntax already.

so the question is about the input still.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: distinct single images from a input pipeline

Post by snibgo »

"mogrify" is useful because it reads one file, processes it and writes its output, then reads the next image, etc. "convert" reads all the inputs before processing any of them, so retains them all in memory at the same time.
maweber wrote:it seems IM6 waits for the whole ffmpeg command to be completed in order to start working on all the images.
IM6 "convert" and IM7 "magick" (by itself) works that way.
maweber wrote:... if IM7 does manage to know when a single ppm is transmitted, and do that image right away, keeping the pipe going, and not buffering more than is needed.
IM6 "mogrify" and IM7 "magick mogrify" work that way, as far as I can tell.

Another question you might ask is: when we pipe, eg from ffmpeg to magick, does the operating system start the second command while the first is still running, or does it wait until the first is finished?

The answer probably depends on the OS and other factors such as system-imposed limits. On my Windows 8.1 laptop, the commands can run simultaneously.
snibgo's IM pages: im.snibgo.com
Post Reply