poldown
poldown

Reputation: 31

Creating a transparent video out of an input video

I'm trying to create a video with a transparent background out of an input video (with the same dimensions, etc.). I tried several strategies (using the chromakey filter and others) and none worked... I got this far:

ffmpeg -i input.mp4 -filter_complex "[email protected],format=yuva420p[bg],[bg][0:v]scale2ref[bg][0v],[bg]drawbox=x=10:y=10:w=100:h=100:[email protected];[0v]nullsink" -c:v qtrle -an "alpha.mov"

It basically works, but the processing never ends - I can't manage to limit the output video length so it'll match the input video's length... I've tried using the -shortest option anywhere in the command - with no success.

Upvotes: 1

Views: 1822

Answers (1)

poldown
poldown

Reputation: 31

Ok, so I managed to solve it with a small trick using overlay filter (specifically - its shortest parameter), with its x and y set to some coordinates outside the relevant bounds, so we're left with the effect of limiting the video's length appropriately:

ffmpeg -i input.mp4 -filter_complex "[email protected],format=yuva420p[bg],[bg][0:v]scale2ref[bg][0v],[bg]drawbox=x=10:y=10:w=100:h=100:[email protected][out];[out][0v]overlay=x=100000:y=100000:shortest=1" -c:v qtrle -an "alpha.mov"

Upvotes: 2

Related Questions