Am I Doing It Right?

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
grum
Posts: 2
Joined: 2016-06-03T14:35:03-07:00
Authentication code: 1151

Am I Doing It Right?

Post by grum »

Hi,
I have recently started looking into ImageMagick to generate a series of frames to be later combined into a movie using ffmpeg. The frames need to simulate a ken burns style pan and zoom where each image will pan and zoom at 30fps for up to 20 seconds (600 frames). Doing this at 1920x1080 is quite processor intensive but i have found a fair bit of optimizations already by running convert concurrently with 20 shell commands and bulk writing out 40 images using mpr.

This is my current code

Code: Select all

./convert source.jpg -interpolate Blend -set option:distort:viewport 1920x1080-0-0 -write mpr:tmp +delete \
  mpr:tmp -distort SRT "0.1,0.0 1.1 0 0,0" -write  "out_1.jpg" +delete \
  mpr:tmp -distort SRT "0.2,0.0 1.1 0 0,0" -write  "out_2.jpg" +delete \
  ....
  mpr:tmp -distort SRT "4.6,0.0 1.1 0 0,0" "out_X.jpg"
Is there a better way of doing this?

Cheers
Graham
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Am I Doing It Right?

Post by snibgo »

That looks good, though I've never used "-interpolate Blend". You are simply panning here (adding a constant to X). If you also want to zoom, multiply the scale number by a constant factor between frames (as you probably know).

I write video scripts so they can be run at any resolution, so I can create the edit list without having to wait for the computer, then render over lunch or overnight at full resolution. For this, you can have "%[fx:...]" expressions in the SRT. You might also have a "-quality" in there, eg "-quality 40" for quick renders, "-quality 100" for high quality.
snibgo's IM pages: im.snibgo.com
grum
Posts: 2
Joined: 2016-06-03T14:35:03-07:00
Authentication code: 1151

Re: Am I Doing It Right?

Post by grum »

Adding the quality gave me some more speed improvements, if i am doing a lower quality codec encoding why have highest quality input frames.
I will have a look at fx, if you have some examples to share that would be great. My zoom and pan will be constant, I was only testing pan above ;) eg pan from X to X + 100 over 600 frames, same with Y and Zoom.

Rendering this out at 1920x1080 with 5 frames at 25fps takes about 150 seconds. Using avfoundation i can do this in 20 seconds. So annoying there is nothing like avfoundation for windows. FFMpeg is almost there but there are problems with ZoomPan. My previous solution using quicktime was taking closer to 500 seconds :P
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Am I Doing It Right?

Post by fmw42 »

You can add -filter point before -distort and use a faster interpolation method. You will lose some quality.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Am I Doing It Right?

Post by snibgo »

grum wrote:I will have a look at fx, if you have some examples to share that would be great.
For some examples of fx with "-distort SRT", see my "Animation with SRT" page.
snibgo's IM pages: im.snibgo.com
Post Reply