Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG color range cropped to 15-235 in RGB

Tags:

colors

ffmpeg

I have a series of BMPs (or PNG) images that I want to convert to XVID and MP5 movie formats.

Encoding works but the resulting movie has a washed out color look to it and the blacks are somehow moved to RGB 16 and the brightest 255 values are moved down to 235. I want the output movie to use the same 0 to 255 colors as the source frames.

Now there are all sorts of conflicting doco out there for FFMPEG so I am hopinbg someone has an example command line that does what I need. I have tried all sorts of pix_fmt flags but none of them get the output movie in the full color range.

For XVID

ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP"  -c:v mpeg4 -vtag xvid -qscale 1 -y "D:\OUTPUT.AVI""

For H265

ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -c:v libx265 -x265-params lossless=1 -s 3840x2160 -pix_fmt yuvj420p -an -y "D:\OUTPUT.MP4""

The yuvj420p is supposed to give the full color range but ffmpeg complains "Incompatible pixel format 'yuvj420p' for codec 'libx265', auto-selecting format 'yuv420p'"

So, are there any FFMPEG gurus out there that can give me the magic switches to get my output movies with black blacks and colors that maintain the original frame files 0-255 RGB values.

like image 302
Some1Else Avatar asked Dec 20 '17 06:12

Some1Else


Video Answer


1 Answers

The output range can be forced, as can the color range metadata, but your player or editor may force a limited range interpretation, So, caveat transcoder.

With that said, you have to set two flags: first one for the scaler, and then for the metadata.

ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -vf format=yuv420p -dst_range 1 -color_range 2 -c:v mpeg4 -vtag xvid -qscale 1 -y "D:\OUTPUT.AVI""

(since you're using mpeg4 encoder, this is not Xvid, which would be -c:v libxvid; you need to have this lib linked in order to to use it.)

For x265, range can be set using an encoder flag.

ffmpeg.exe -framerate 60 -i "D:\SRC%05d.BMP" -c:v libx265 -x265-params lossless=1:range=full -s 3840x2160 -dst_range 1 -pix_fmt yuv420p -an -y "D:\OUTPUT.MP4""
like image 117
Gyan Avatar answered Nov 15 '22 13:11

Gyan