6

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.

1 Answer 1

11

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""
Sign up to request clarification or add additional context in comments.

6 Comments

Perfect. My output is now the full 0-255 range. I did read that some players may crop etc but in my case these movies are for uploading to YouTube and as long as the source is 0-255 then YouTube does not crop or stretch into the 15-235 range.
@gyan how did you find this? I cannot even find the word color_range or dst_range in ffmpeg document.
color_range is a libavcodec option - hints the decoder or encoder. dst_range is libswscale option - gets passed onto any scaling or pixel format operations.
Do you know how to do this with webm (libvpx)? I have searched high and low and I cannot find an answer.
@felwithe Appears to be used only by VP9. WebM should store flag nonetheless.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.