[FFmpeg-user] Use of "-color_range"

Thomas Worth dev at rarevision.com
Tue Jul 5 09:30:50 CEST 2011


On Mon, Jul 4, 2011 at 11:33 PM, Tim Nicholson <tim.nicholson at bbc.co.uk> wrote:
> On 04/07/11 18:13, Thomas Worth wrote:
>>
>> On Mon, Jul 4, 2011 at 7:44 AM, Tim Nicholson<tim.nicholson at bbc.co.uk>
>>  wrote:
>>>
>>> I am struggling to find any documentation on the use of this and
>>> searching
>>> the source was not very revealing, to my eye at least.
>>>
>>> Apart from the fact that it expects an<int>  I am none the wiser.
>>>
>>> I since it is a DEV function I was hoping I could use it to force ffmpeg
>>> to
>>> handle source material of a non standard range.
>>
>> Regarding this and x264 encoding: I had some full range 4:2:2 material
>> I was trying to encode with x264 a while back and found that if I
>> forced the "yuvj420p" pix format, FFmpeg would pass full range values
>> to x264. This was using x264 in pipe mode, but I don't see why it
>> wouldn't work with libx264. I would get very different results when
>> changing yuv420p to yuvj420p.
>
> Quite! Except that if you look at pixfmt.h it says (line 74)
>
> "PIX_FMT_YUVJ420P,  ///< planar YUV 4:2:0, 12bpp, full scale (JPEG),
> deprecated in favor of PIX_FMT_YUV420P and setting color_range"
>
> Which begs the original question.

Does this help? From libavcodec/h264.c:

        switch (h->sps.bit_depth_luma) {
            case 9 :
                s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P9 :
PIX_FMT_YUV420P9;
                break;
            case 10 :
                s->avctx->pix_fmt = CHROMA444 ? PIX_FMT_YUV444P10 :
PIX_FMT_YUV420P10;
                break;
            default:
                if (CHROMA444){
                    s->avctx->pix_fmt = s->avctx->color_range ==
AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P;
                }else{
                    s->avctx->pix_fmt = s->avctx->get_format(s->avctx,

s->avctx->codec->pix_fmts ?

s->avctx->codec->pix_fmts :

s->avctx->color_range == AVCOL_RANGE_JPEG ?

hwaccel_pixfmt_list_h264_jpeg_420 :

ff_hwaccel_pixfmt_list_420);
                }
        }


More information about the ffmpeg-user mailing list