Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make green nullsrc to black

Tags:

colors

ffmpeg

I have a video which hasn't 1920x1080 so I need to make it.

I try to use next command:

ffmpeg -i "video.avi" -filter_complex "nullsrc=size=1920x1080 [0:v]; [0:v] overlay=shortest=1:x=200:y=100" -r 30 -c:v libx264 -preset fast -crf 18 -profile:v high -bf 2 -flags +cgop -coder 1 -pix_fmt yuv420p -strict -2 -c:a aac -b:a 384k "video.mp4"

But I got a green frame over the video like this - https://i.sstatic.net/Fzw4w.jpg

I dont find a solution to make a green in any other color.

How possible to make green frame to black frame?

Thanks.

like image 555
Ultgin Avatar asked Jul 05 '26 20:07

Ultgin


1 Answers

Use the pad filter instead

It is simpler to just use the pad filter to add the frame:

ffmpeg -i input -filter_complex "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output

Not as efficient alternatives

Alternatively, if you want to use the overlay filter to add padding then you can use the color source filter instead of nullsrc:

ffmpeg -f lavfi -i color=s=1920x1080:c=black -i video.mp4 -filter_complex "[0][1]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1" output.mp4

If you still want to use nullsrc then refer to the chromakey filter, but this is inefficient and not a recommend method.

like image 197
llogan Avatar answered Jul 08 '26 21:07

llogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!