Reputation: 13
I'm trying to render an image over a video. I use the following command after some research
ffmpeg -y -i "my_video.mp4" -i "my_image.jpg" -filter_complex "color=color=blue:size=711x400:rate=25[container];[0:v]scale=w=400:h=400,setpts=expr=PTS-STARTPTS[vidscaled];[container][vidscaled]overlay=eval=init:shortest=1:x=155:y=0[overlay0];[1:v]scale=w=123:h=123,rotate=a=323.7*PI/180:c=black@0:oh='roth(323.7*PI/180)':ow='rotw(323.7*PI/180)':bilinear=1[imgproc];[overlay0][imgproc]overlay=eval=init:x=18:y='237-abs(123*sin(323.7*PI/180))'[overlay1]" -map "[overlay1]" -map 0:a -strict -2 -preset ultrafast -g 120 output.mp4
The problem with this approach is a low image's quality since scaling is applied before rotate. So i tried to apply the rotation before scaling, (see next command)
ffmpeg -y -i "my_video.mp4" -i "my_image.jpg" -filter_complex "color=color=blue:size=711x400:rate=25[container];[0:v]scale=w=400:h=400,setpts=expr=PTS-STARTPTS[vidscaled];[container][vidscaled]overlay=eval=init:shortest=1:x=155:y=0[overlay0];[1:v]rotate=a=323.7*PI/180:c=black@0:oh='roth(323.7*PI/180)':ow='rotw(323.7*PI/180)':bilinear=1,scale=w=173:h=173[imgproc];[overlay0][imgproc]overlay=eval=init:x=18:y='237-abs(123*sin(323.7*PI/180))'[overlay1]" -map "[overlay1]" -map 0:a -strict -2 -preset ultrafast -g 120 output.mp4
And the problem: c=black@0 is not working anymore, the bounding box around the rotated image is not transparent.
Anyone please help this soul.
pd: Using c=none doesn't work too, got a green background
Upvotes: 1
Views: 750
Reputation: 93221
Can't test this at the moment but adding an alpha plane beforehand should do the trick.
[1:v]format=yuva444p,rotate=a=323.7*PI/180:c=black@0:oh='roth(323.7*PI/180)':ow='rotw(323.7*PI/180)':bilinear=1,scale=w=123:h=123[imgproc];
Upvotes: 1