[FFmpeg-devel] [PATCH] vf_overlay: Add `timebase` option to set the time base source for the output video.

Vittorio Gambaletta (VittGam) ffmpeg-dev at vittgam.net
Thu Mar 10 20:28:28 CET 2016


On 10/03/2016 19:14:10 CET, Michael Niedermayer wrote:
> On Tue, Feb 09, 2016 at 09:12:53PM +0100, Paul B Mahol wrote:
>> On 1/20/16, Vittorio Gambaletta (VittGam) <ffmpeg-dev at vittgam.net> wrote:
>> > With this commit it is possible to use vf_overlay to center a video over
>> > a black background, without having to know the video framerate in advance
>> > and set it as parameter to lavfi.
>> >
>> > Signed-off-by: Vittorio Gambaletta <ffmpeg-dev at vittgam.net>
>> > ---
>> >  doc/filters.texi         |   14 ++++++++++++++
>> >  libavfilter/vf_overlay.c |   14 +++++++++-----
>> >  2 files changed, 23 insertions(+), 5 deletions(-)
>> >
>>
>> Pardon me, could you give command example where this is useful but
>> currently does not work,
>> but does work with this patch applied?
>
> cc-ing the author of the patch ...

Thanks Michael for the CC.

This is useful where you generate the black background with lavfi, so it
is the main video for the overlay, and you don't know the framerate for
the secondary video in advance, but this secondary video is actually the
video that you want to center over the black background. So the "master"
timebase should be set from the secondary video in this case.

This is an example command line. I hope this is the correct one, it should
dynamically center the input video in a 720x400 box with 16:9 aspect ratio.

ffmpeg -f lavfi -i testsrc=s=720x400:r=25 -i {input} -filter_complex '[1:v:0] scale=width=min(720\,720/16*9*dar):height=min(400\,720/dar):eval=frame:flags=lanczos [out1]; [out1] [0:v:0] overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2:eval=frame:shortest=1,setdar=r=16/9 [finalv]' -map finalv -map 1:a:0? {output}

Without the patch, the output video will always have 25 fps. With the patch
and related parameter, it can ignore the 25 and have the framerate of the
overlaid video.


More information about the ffmpeg-devel mailing list