John
John

Reputation: 43

How to set the same size for the input color as the video size?

I have many videos with different widths and heights on which I need to overlay a random color. And I don't know how to set the same size for the color input as the size of each of all of my videos...

The exact color size only works for the video with the same size. But when the queue comes to another video with different width and height the error popping up.

enter image description here

for %%i in (*.mp4) do ffmpeg /
-i "%%i" -f lavfi -i "color=random@1:s=624x1110" /
-hide_banner -y -c:v libx264 -preset slow /
-filter_complex /
"[0:v]setsar=sar=1/1[ckout]; /
 [ckout][1:v]blend=shortest=1:all_mode=overlay:all_opacity=0.05[out]" -map "[out]" "output/%%~ni.mp4"

Upvotes: 1

Views: 650

Answers (1)

Gyan
Gyan

Reputation: 92928

Use the scale2ref filter,

ffmpeg /
-i "%%i" -f lavfi -i "color=random@1:s=32x32" /
-hide_banner -y -c:v libx264 -preset slow /
-filter_complex /
"[0:v]setsar=sar=1/1[ckout];[1][ckout]scale2ref[clr][ckout]; /
 [ckout][clr]blend=shortest=1:all_mode=overlay:all_opacity=0.05[out]" -map "[out]" "output/%%~ni.mp4"

Alternatively, just use drawbox filter.

ffmpeg -i "%%i" -hide_banner -y -c:v libx264 -preset slow /
-vf "setsar=1,drawbox=t=fill:[email protected]" "output/%%~ni.mp4"

Upvotes: 2

Related Questions