mlt

MLT Move video upper?


Had to make something like this, but i can't find way how to move video which is at middle a bit upper...

enter image description here

melt in.mp4 
-filter watermark:"title.jpg" composite.progressive=1 producer.align=centre composite.valign=top composite.halign=c
-filter watermark:"bottom.jpg" composite.progressive=1 producer.align=centre composite.valign=bottom composite.halign=c
-filter crop left=128 right=128 
-profile square_profile.txt -consumer avformat:"out.mp4" vcodec=libx264 vb=3500k ab=128k 

So how to move centered video upper? Can't find such filter...


Solution

  • The "affine" filter can be used to change the size and position of the video frame: https://mltframework.org/plugins/FilterAffine/

    The affine filter is really just a convenience wrapper that combines a black producer (for the background) and an affine transition: https://mltframework.org/plugins/TransitionAffine/

    You can modify the affine transition properties by setting "transition.*" properties on the affine filter. For example, to set the size and position of the frame, use "transition.geometry".

    melt in.mp4 -filter affine transition.geometry="-40/40:700x500" transition.distort=0 transition.fill=0 \
        -filter watermark:"bottom.jpg" composite.progressive=1 producer.align=centre composite.valign=bottom composite.halign=c \
        -filter watermark:"bottom.jpg" composite.progressive=1 producer.align=centre composite.valign=bottom composite.halign=c \
        -profile square_profile.txt -consumer avformat:"out.mp4" vcodec=libx264 vb=3500k ab=128k
    

    The geometry specification is: "X/Y:WxH". So set those according to your needs. The X and Y values can be negative in order to crop off parts that you don't want to display.