[FFmpeg-user] filters zoompan and crop

Jim DeLaHunt list+ffmpeg-user at jdlh.com
Mon Oct 29 08:07:43 EET 2018


On 2018-10-26 11:57, S Andreason wrote:
> Hi,
>
> Does zoompan not work outside the range 1 .. 8?
>
Nearly correct. The zoompan filter accepts values for the zoom parameter 
between 1 and 10. Any values below 1.0 are set to 1; any values greater 
than 10.0 are set to 10.

Also, it's helpful to be very clear about the conceptual model the 
zoompan filter uses. The filter starts with an input image (or frame of 
an input video). It sets up a coordinate system based on this image: 
origin at top-left, with +x to the right and +y downwards.  A zoom 
argument of /k/ is interpreted as if the input image was drawn /k /times 
its original size, or equivalently, that the output image is 1//k/ the 
size of the input image. The x and y arguments to the zoompan filter are 
interpreted in this coordinate system, but clipped so that the output 
image (after zoom adjustment) will stay completely within the input image.

The core motivation for the filter seems to be implementing what some 
call the "Ken Burns effect", making a video image which pans over an 
input image, and zooms in to only show part of the image at a time. It 
is not well-suited to general transformations, given its limitations on 
zoom level, its refusal to pan beyond the boundary of the input image, 
and the absence of a rotation capability or generalised affine 
coordinate transformations.

> I want to generate an overlay to zoom in, have the input png start 
> small, and grow to half the video size, like from 20 to 320 in width. 
> Starting the zoompan at z=0.1 does not seem to work.
Take a look at the *pad* filter <http://ffmpeg.org/ffmpeg-all.html#pad>. 
That generates an output frame which consists of an input frame with 
padding around it.
> Also if the first filter was successful, I need to crop it so that it 
> grows over time. I am having trouble getting crop to adjust based on 
> the frame number. From my testing it seems n in this case starts at 0 
> when the enable between starts, instead of the output video frame 
> number like the other filters I have been using.
I'm not sure I follow what you mean by "when the enable between starts". 
My experience with the *zoompan* filter is that the /in/ parameter 
(input frame number) is 2 for the first frame, rather than 0 as is usual 
for ffmpeg. I think that this is partly a bug (see 
<https://trac.ffmpeg.org/ticket/7242>). Partly this appears to be a 
design decision by the original developer, to use cardinal numbers 
instead of ordinal numbers.
> Is there a manual or wiki with more information then at
> https://ffmpeg.org/ffmpeg-filters.html ?
If you want to do serious work with the zoompan filter, my experience is 
that the documentation isn't adequate, and you need to read the source 
code in ffmpeg/libavfilter/vf_zoompan.c, lines 153-250, function 
output_single_frame().
> Thank you
>
I hope this is helpful for you.
       —Jim DeLaHunt, Vancouver, Canada

-- 
     --Jim DeLaHunt, jdlh at jdlh.com     http://blog.jdlh.com/ (http://jdlh.com/)
       multilingual websites consultant

       355-1027 Davie St, Vancouver BC V6E 4L2, Canada
          Canada mobile +1-604-376-8953



More information about the ffmpeg-user mailing list