I need to overlay multiple images with animated position, alpha and rotation on recorded video. What's the best way to accomplish this?
Currently I'm looking at ffmpeg, is it possible to add position animation to overlays using ffmpeg?
ffmpeg -y -i video.mp4 -i overlay.png -filter_complex "[0][1]overlay=x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080)[res];" -map "[res]" -preset ultrafast out.mp4
Overlay input [1] (overlay.png) over input [0] (video.mp4) and position overlay using evaluation x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080), where t = time in milliseconds. Then map overlay result to stream [res], and output to out.mp4.
A more complex example with multiple overlays and using gif as overlay:
ffmpeg -y -i video.mp4 -ignore_loop 0 -i overlay.gif -filter_complex `
>> "[0][1]overlay=x=mod((1080/4 + sin(t)*1080/4)\,1920):y=mod(t*300\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*1 + 1080/4 - sin(2*t)*1080/4)\,1920):y=mod(100 + t*300\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*2 + 1080/4 - sin(-90 + t/2)*1080/4)\,1920):y=mod(150 + t*250\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*3 + 1080/4 - sin(90 + 3*t)*1080/4)\,1920):y=mod(200 + t*100\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*4 + 1080/4 - sin(180 + t)*1080/4)\,1920):y=mod(t*250\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*5 + 1080/4 - sin(-180 + t)*1080/4)\,1920):y=mod(t*100\,1080):shortest=1[res];`
>> [res][1]overlay=x=mod((200*6 + 1080/4 - sin(2*t)*1080/4)\,1920):y=100 + mod(100 + t*300\,1080):shortest=1[res]`
>> " -map "[res]" -preset ultrafast out.mp4
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments