different zoom for horizontal and vertical axes
Hi, I want to make a video effect where the zoom factor is changing with a sine function, like in this example: ffmpeg -i in.mov -lavfi zoompan=z='1.2+0.1*sin(3*time)':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)' -t 10 -y out.mov But I want different functions for horizontal and vertical zoom. For example sin() for horizontal and cos() for vertical zoom. That's not possible with the zoompan filter. Which other filter can I use instead? Thanks, Michael
On 2025-09-14 11:26 pm, Michael Koch via ffmpeg-user wrote:
But I want different functions for horizontal and vertical zoom. For example sin() for horizontal and cos() for vertical zoom. That's not possible with the zoompan filter. Which other filter can I use instead?
Can you share a visual reference? Regards, Gyan
like this video: https://www.youtube.com/watch?v=LsxJe6yW0QU I did make it with geq filter, but that's extremely slow because the same function must be calculated for each pixel. It's a simulation how a gravitational wave from a _very_ close source would look like. One axis is sin(), other axis is cos(). If we see something like this in reality, then life is over. Michael
On 2025-09-15 12:44 am, Michael Koch via ffmpeg-user wrote:
like this video: https://www.youtube.com/watch?v=LsxJe6yW0QU I did make it with geq filter, but that's extremely slow because the same function must be calculated for each pixel.
One method that comes to mind is to use scale+crop cascade scale=eval=frame:h=ih:w=f1(t),crop=W:H,scale=eval=frame:w=iw:h=f2(t),crop=W:H Make sure that no resultant frame from scale produces a frame smaller than WxH, so pad first if needed. Regards, Gyan
The idea is good, but now there is another problem. The neutral point (the point which is not moving) is now in top left corner. Obviously I must also set the x and y options in the crop filter (using 50% of the functions f1 and f2). But these expressions aren't evaluated for each frame. Unfortunately the crop filter doesn't have the eval=frame option. It might perhaps work with sendcmd. Michael
On 2025-09-15 12:31 pm, Michael Koch via ffmpeg-user wrote:
The idea is good, but now there is another problem. The neutral point (the point which is not moving) is now in top left corner. Obviously I must also set the x and y options in the crop filter (using 50% of the functions f1 and f2). But these expressions aren't evaluated for each frame. Unfortunately the crop filter doesn't have the eval=frame option. It might perhaps work with sendcmd.
Dynamic crop does work with sendcmd. The filtergraph gets unwieldy quick, so you need to compose it in a file. Regards, Gyan
It did work with scale and crop. It wasn't necessary to use sendcmd. Here is the result: https://www.youtube.com/watch?v=YllBiFxKbFY Thanks for your help! Michael
participants (3)
-
astroelectronic@t-online.de -
Gyan Doshi -
Michael Koch