Changes between Initial Version and Version 1 of BouncingOverlay


Ignore:
Timestamp:
Nov 28, 2021, 12:07:38 AM (5 years ago)
Author:
Pascal S
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BouncingOverlay

    v1 v1  
     1= Create a sliding and bouncing overlay =
     2
     3In this example, the foreground video slides over the background one and bounces on the four edges. The output audio stream selected is the background one.
     4
     5It can be used "as-is" under Windows. Unix users should replace ending `^` by `\`. The command line below has been splitted to make it more understandable.
     6
     7{{{
     8ffmpeg -i "background.mp4" -i "foreground.mp4" -filter_complex ^
     9overlay='^
     10if(eq(mod(floor(st(8,t*320)/(W-w)),2),0),^
     11mod(ld(8),W-w),^
     12W-w-mod(ld(8),W-w))^
     13:^
     14if(eq(mod(floor(st(9,t*140)/(H-h)),2),0),^
     15mod(ld(9),H-h),^
     16H-h-mod(ld(9),H-h))^
     17:^
     18eval=frame^
     19:^
     20repeatlast=1^
     21' ^
     22"OUTPUT.mp4"
     23}}}
     24
     25This example works properly with a 1080p (16/9) background and a 360p (16/9) foreground but can be modified to work with any scale.
     26
     27The horizontal speed (t*320) and the vertical one (t*140) can be tuned. They are stored in internal variables 8 and 9 to avoid duplicates.
     28
     29Pay attention to the input durations and use either '''repeatlast''' or '''shortest''' options of the overlay filter.
     30
     31Have in mind that frames are taken from each input video in timestamp order, hence, if their initial timestamps differ, it is a good idea to pass the two inputs through a '''setpts=PTS-STARTPTS''' filter to have them begin in the same zero timestamp.