kostya572
kostya572

Reputation: 169

How to merge webm video with mp4 video with transperency?

I have 1080p webm video and 500x300 mp4 video. How could I place muted mp4 video on top-center position of webm video with transparency? The output file format needed ".webm". Here what similar code I found, but it uses two mp4 videos and second video scales full width on front of first one: ffmpeg \ -i in1.mp4 -i in2.mp4 \ -filter_complex " \ [0:v]setpts=PTS-STARTPTS, scale=480x360[top]; \ [1:v]setpts=PTS-STARTPTS, scale=480x360, \ format=yuva420p,colorchannelmixer=aa=0.5[bottom]; \ [top][bottom]overlay=shortest=1" \ -vcodec libx264 out.mp4

Output log: Output log:

Upvotes: 1

Views: 1099

Answers (1)

Gyan
Gyan

Reputation: 93028

Use

ffmpeg \
        -i in1.webm -i in2.mp4 \
        -filter_complex " \
            [0:v]setpts=PTS-STARTPTS[base]; \
            [1:v]setpts=PTS-STARTPTS, \
                 format=yuva420p,colorchannelmixer=aa=0.5[overlay]; \
            [base][overlay]overlay=x=(W-w)/2:y=0[v]"
        -map "[v]" -map 0:a -c:a copy -shortest out.webm

The output file won't have the input webm's transparency but it can be done if required.

Upvotes: 1

Related Questions