VideoHelp Forum

+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hello, I need multiple alpha-layered animations to be combined into a single MP4. Currently using the following script but it only successfully layers layer1 on top of the background .png. All animations are the same resolution. Does anyone know a good way to script this?

    Code:
    "ffmpeg -i background.png -i layer1.mov -i layer2.mov -i layer3.mov -filter_complex 'overlay' + out.mp4"
    Quote Quote  
  2. Originally Posted by Mugunga View Post
    Hello, I need multiple alpha-layered animations to be combined into a single MP4. Currently using the following script but it only successfully layers layer1 on top of the background .png. All animations are the same resolution. Does anyone know a good way to script this?

    Code:
    "ffmpeg -i background.png -i layer1.mov -i layer2.mov -i layer3.mov -filter_complex 'overlay' + out.mp4"


    Assuming you want an end distribution format like AVC, 4:2:0 , no audio, layered in that order where layer3 is the topmost layer, it would look something like this

    Code:
    ffmpeg -r 24 -i background.png -i layer1.mov -i layer2.mov -i layer3.mov -filter_complex "[0:v][1:v]overlay[ov1], [ov1][2:v]overlay[ov2], [ov2][3:v]overlay[ov3], [ov3]scale=out_color_matrix=bt709,format=yuv420p[out]" -map [out] -c:v libx264 -crf 20 -an -shortest output.mp4
    Quote Quote  
  3. Thank you! That worked. Very fast and thorough reply, I appreciate it!
    Quote Quote  
  4. Where it says -r 24 (before -i background) , you should change that to the actual framerate of the video assets (layer1.mov etc...) . If they were 24/1 fps, then -r 24 is ok. But if they were 30/1 fps, then use -r 30 , otherwise you will get dropped/duplicated frames.
    Quote Quote  
  5. Hey, a follow up question here...do you know what the syntax would be if i need to stack multiple .pngs and THEN put the animations on?
    HTML Code:
    ffmpeg -i background.png -i overlayimage1.png -i overlayimage2.png -i animation1.mov -i animation2.mov -filter_complex "?????????????, [ov1][2:v]overlay[ov2], [ov2][3:v]overlay[ov3], [ov3]scale=out_color_matrix=bt709,format=yuv420p[out]" -map [out] -c:v libx264 -crf 20 -an -shortest output.mp4
    Quote Quote  
  6. Originally Posted by Mugunga View Post
    Hey, a follow up question here...do you know what the syntax would be if i need to stack multiple .pngs and THEN put the animations on?
    HTML Code:
    ffmpeg -i background.png -i overlayimage1.png -i overlayimage2.png -i animation1.mov -i animation2.mov -filter_complex "?????????????, [ov1][2:v]overlay[ov2], [ov2][3:v]overlay[ov3], [ov3]scale=out_color_matrix=bt709,format=yuv420p[out]" -map [out] -c:v libx264 -crf 20 -an -shortest output.mp4

    The same way - look at the pattern. Just add on 4:v and ov4 because you have 5 inputs instead of 4 . So there should be 4 overlays instead of 3 . You can use different names or labels instead of ov1, ov2, etc... They are just names for input/output nodes

    0:v is the 1st video input
    1:v is the 2nd video input
    2:v is the 3rd video input
    .
    .

    Code:
    -filter_complex "[0:v][1:v]overlay[ov1], [ov1][2:v]overlay[ov2], [ov2][3:v]overlay[ov3], [ov3][4:v]overlay[ov4], [ov4]scale=out_color_matrix=bt709,format=yuv420p[out]"
    Quote Quote  
  7. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Just my preference but I use Avisynth because the timings for each overlay, position, and duration can be set. You can also mix and match Images/videos for different base file and mixed overlays. Below I have a image as the base file and overlay both image and video. Setup is shown below. Takes a little thought at first but may be of help to others.

    Code:
    v1=imageSource("C:\Users\Bud\Desktop\diz.jpg",fps=30).converttoRGB32.LanczosResize(854,480)
    Image11=DirectShowSource("C:\Users\Bud\Desktop\test.mp4").converttoRGB32.LanczosResize(160,90).trim(0,49)
    Image12=DirectShowSource("C:\Users\Bud\Desktop\test.mp4").converttoRGB32.LanczosResize(160,90).trim(50,99)
    Image22=imageSource"("("C:\Users\Bud\Desktop\diz.jpg").converttoRGB32.LanczosResize(160,90).trim(0,49)
    Image23=imageSource"("("C:\Users\Bud\Desktop\diz.jpg").converttoRGB32.LanczosResize(160,90).trim(50,49)
    Image24=imageSource"("("C:\Users\Bud\Desktop\diz.jpg").converttoRGB32.LanczosResize(160,90).trim(50,99)
    Image33=DirectShowSource("C:\Users\Bud\Desktop\test.mp4").converttoRGB32.LanczosResize(160,90).trim(0,-1)
    Image34=DirectShowSource("C:\Users\Bud\Desktop\test.mp4").converttoRGB32.LanczosResize(160,90).trim(0,49)
    Image35=DirectShowSource("C:\Users\Bud\Desktop\test.mp4").converttoRGB32.LanczosResize(160,90).trim(50,99)
    Clip1=v1.trim(0,49).Overlay(image11, 10,10 ,Opacity=1.0,image11.ShowAlpha()) \
    ++ v1.trim(50,99).Overlay(image12, 10,10 ,Opacity=1.0,image12.ShowAlpha()).Overlay(image22, 10,110 ,Opacity=1.0,image22.ShowAlpha()) \
    ++ v1.trim(100,99).Overlay(image23, 10,110 ,Opacity=1.0,image23.ShowAlpha()).Overlay(image33, 10,210 ,Opacity=1.0,image33.ShowAlpha()) \
    ++ v1.trim(100,149).Overlay(image24, 10,110 ,Opacity=1.0,image24.ShowAlpha()).Overlay(image34, 10,210 ,Opacity=1.0,image34.ShowAlpha()) \
    ++ v1.trim(150,199).Overlay(image35, 10,210 ,Opacity=1.0,image35.ShowAlpha()) \
    ++ v1.trim(200,0)
    return Clip1
    P.S. (I Cheat)

    Image
    [Attachment 61567 - Click to enlarge]
    Quote Quote