S
S
Sergey Pugovkin2019-07-29 17:14:41
PHP
Sergey Pugovkin, 2019-07-29 17:14:41

How to merge video from several images and their zoom in ffmpeg?

There are several images. It is necessary to zoom each in for 2 seconds, by 10%, from the center, and then display each image for 5 seconds. And on top of each image, overlay another specific png, and which should not participate in the zoom.
Video must be 640x480
Is it possible to do this with ffmpeg alone? How?
PS While there is an option to generate frames in advance (php + gd) and already glue them in ffmpeg, but so far this is not very good, especially with zoom (because a pixel is not divisible by 2, and a jerky zoom is obtained).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-07-29
@sergiks

Everything described can be done in ffmpeg.
The animated zoom is done by the zoompan filter . It works with only integer coordinates, therefore, in order not to twitch, do it in high resolution. Then downsample.
For example, from a recent project where an animation was interactively generated from a template, this is from a bash script:

FILTER="[0]                                                   \
    pad=color=0x99999900:w=${wIn}:h=${hIn}:x=${xPad}:y=${yPad}, \
    scale=20064x3264,                                           \
    zoompan=                                                    \
      s=${wSrc}x${hSrc}                                         \
      :d=${frames}                                              \
      :z='( ${zoomcode} ) / 16.89999'                           \
      :x='2*(${xPad} + ${xPoi}) * (zoom - 1) / zoom'            \
      :y='2*(${yPad} + ${yPoi}) * (zoom - 1) / zoom'            \
      [fg];                                                     \
      [1][fg]overlay=x=247:y=438                                \
  "

Because it is impossible to zoom in less than it fits into the viewport, first a transparent padding is added around the edges of the picture so that it can be reduced. Then the size is increased by a margin of 5-10 times to make the integer pixel steps of zoom and offset invisible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question