[FFmpeg-user] convert from bt601 to bt709

Bob Maple bobm-ffmpeg at burner.com
Wed Jun 11 00:32:36 CEST 2014


On 6/10/2014 8:39 AM, Carl Eugen Hoyos wrote:

> I was unable to find a possibility to make FFmpeg assume 
> MPEG range for the input sample (and I was unable to find 
> any hint within the dpx file that it is not full scale 
> which is expected for rgb afaict, if somebody could help 
> with the detection, it would be useful!)

It's the "Transfer" byte at 0x321 right after the descriptor byte (0x320
in the header which specifies RGB, RGBA, etc.)  ffmpeg currently skips
over it (along with the Colorimetric byte that follows it at 0x322.)

While it can be a bunch of different things (Linear, Log..) in general
it will be 6 for 709 levels, or 0 for full-range RGB levels (which is
actually "user defined")

> you currently have to cheat:
> 
> $ ffmpeg -i input.dpx -f rawvideo 
> -sws_flags full_chroma_inp+full_chroma_int+accurate_rnd+print_info 
> -pix_fmt yuvj422p out
> 
> (You could probably compress the output, in any case you 
> can use -f image2 -vcodec rawvideo if that suits your 
> needs better.)

I can't get this to work for more practical applications like going to
DNxHD or even uncompressed 8 or 10-bit.  The -sws_flags seem to have no
affect on the result. And you can't use -pix_fmt yuvj422p because DNxHD
(and others) don't allow it:

  Incompatible pixel format 'yuvj422p' for codec 'dnxhd', auto-selecting
format 'yuv422p'

(Really we want the _source_ format to be able to be interpreted as
yuvj422p (I think?) or whatever it means so as NOT to scale the dynamic
range when going to other formats like yuv422p, yuv422p10, etc.)

> $ ffmpeg -f rawvideo -s 1920x1080 -r 24000/1001 -pix_fmt yuv422p 
> -i out -vcodec dnxhd -vb 115M -movflags +faststart out.mov
> 
> Note the different colour spaces used for writing and reading.
> Above may not be perfect but since you are converting 
> from 10bit to 8bit with subsampling I would (perhaps 
> wrongly?) assume that the output does not have to 
> be perfect.

Sure (although it's worth pointing out there are some 10-bit versions of
DNxHD, which ffmpeg supports though I haven't played with it extensively
- but yuv422p10 at 175M could be substituted in the above example)

> I would open a ticket but I am still hoping for a 
> checkerboard or at least a dpx sample with large 
> white and black areas.

Here's a very simple 10-bit RGB DPX at 709 levels.  It's 1920x1080; the
top 540 lines are black 64/64/64.  The bottom 540 lines are white
940/940/940.

http://clients.idolum.com/get/3f8e593cd892

The goal would be to be able to convert it to DNxHD Quicktime,
Uncompressed 8/10-bit Quicktime, or even ProRes Quicktime for instance
and not have ffmpeg re-scale the levels when it converts RGB->YUV,
because they are already scaled in the source.

Bob


More information about the ffmpeg-user mailing list