VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 12 of 12
Thread
  1. I've read a little about color space and matrix but I am unsure what to do at encoding time. For example I have a source that is reported by MediaInfo as YUV 4:2:0 with "Format settings, Matrix" as "Default". What even is default? Considering the source is NTSC DVD, should I treat it as BT.601? If I do not specify anything during encoding, the resulting video will hold not information pertaining to the color matrix, and the color will be displayed exactly like the source. If I enforce BT.709 then the colors are slightly altered, but I am not entirely sure which is the correct one. I am wondering considering that a software like Handbrake will default to BT.709.

    I would suppose that SD sources should be BT.601 and HD sources should be BT.709 but then again, it's just a guess at this point.
    Quote Quote  
  2. Originally Posted by ZetaStax View Post
    Format settings, Matrix" as "Default". What even is default?
    This has to do with the MPEG2 quantization matrix, not the color matrix

    Considering the source is NTSC DVD, should I treat it as BT.601?
    yes

    If I do not specify anything during encoding, the resulting video will hold not information pertaining to the color matrix, and the color will be displayed exactly like the source.
    You can do nothing (in terms of converting the actual colors), just flag it as BT.601 so other hardware/software that look for flags can see it. This won't hurt and can only potentially help


    I would suppose that SD sources should be BT.601 and HD sources should be BT.709
    Yes
    Quote Quote  
  3. Thank you for clearing that up poisondeathray. Looking up ffmpeg documentation I have found a few different options related to color coding. color_primaries, color_trc and colorspace all seem to be simple flags, but the description says that the default value is 'auto' (Keep the same colorspace property) which makes me doubt what it actually does. There is also the filter out_color_matrix although it sounds more of a conversion pipeline than anything.

    Also when I set these flags MediaInfo also reports 'color range' as 'limited' should it be set to full?
    Quote Quote  
  4. Originally Posted by ZetaStax View Post
    Thank you for clearing that up poisondeathray. Looking up ffmpeg documentation I have found a few different options related to color coding. color_primaries, color_trc and colorspace all seem to be simple flags, but the description says that the default value is 'auto' (Keep the same colorspace property) which makes me doubt what it actually does. There is also the filter out_color_matrix although it sounds more of a conversion pipeline than anything.
    In the past, those flags actually converted stuff (not just flags) . I think the current behaviour is flagging only, not entirely sure

    out_color_matrix as part of -vf scale argument is for YUV<=>RGB conversions . That definitely converts




    Also when I set these flags MediaInfo also reports 'color range' as 'limited' should it be set to full?
    No . And DVD is never "full" range , at least not retail ones


    What are you feeding into FFMpeg directly ? Is it a script or MPEG2/VOB?

    Is DVD telecined, or interlaced ?

    What is the aspect ratio ?

    What is the desired output format ? / How is it going to be played ?

    If using something like x264/x265, I prefer to explicitly specify the flags in the encoder options
    Quote Quote  
  5. I'm feeding ffmpeg with an AviSynth+ script, where the source is loaded using DGSource. I'm using x264 and as far as compatibility goes I want this to play on the computer as well as on the TV through Kodi. Everything I've encoded so far is working properly so I don't think it's too much of a concern, but if I can flag the colorspace correctly, that's all the better. Fun fact, those flags do not have an option for BT.601
    Quote Quote  
  6. Originally Posted by ZetaStax View Post
    If I do not specify anything during encoding, the resulting video will hold not information pertaining to the color matrix, and the color will be displayed exactly like the source.
    Maybe with your current setup. But it may be different if you use a different media player or graphics card. Some media players always use one matrix or the other. Some will use rec.601 for SD material, rec.709 for HD material. Some will follow the flagged matrix, some not.

    The color matrix controls how YUV video becomes RGB for display on the monitor/TV (and how RGB video became YUV in the first place). The general rule is you should use rec.601 for standard definition video, rec.709 for high definition video. If you upscale SD video to HD convert the color matrix from rec.601 to rec.709. And flag the color matrix correctly in your encoding. That way you will have the best chance of having your video displayed correctly.

    Note that if you recompress a YUV source (like DVD) to YUV output without any intermediate conversion to RGB then the it remains with the original colorspace. Ie, rec.601 remains rec.601, rec.709 remains rec.709. You should still flag the matrix.

    Originally Posted by ZetaStax View Post
    Fun fact, those flags do not have an option for BT.601
    Use smpte170m.
    Quote Quote  
  7. Alright, things are clearer now. I've also confirmed that the three flags colorspace color_primaries and color_trc can all be set without reencoding, so there isn't any colorspace conversion. I'm still unsure whether all three should be set or not, it seems only colorspace has an impact on the resulting video.
    Quote Quote  
  8. ColorSpace is a different thing, to be fussy about terminology.

    "Transfer" = gamma. Rec.709 and Rec.601 are the same, but for DVDs you can use bt470bg for PAL and smpte170m for NTSC.
    "Primaries" specifies the color primaries. HD, NTSC and PAL use slightly different primaries.
    The chances of a player paying any attention to either of those is probably incredibly low.

    "Matrix" is the important one. I set all three options for Rec.709, but for SD I only set Color Matrix. If memory serves me correctly, when encoding DVDs, Handbrake sets Rec.709 for the first two and either bt470bg or smpte170m for the Matrix.

    I suspect Handbrake uses Rec.709 for the primaries because HD displays are generally calibrated for Rec.709 primaries, and in some respect Rec.709 was a compromise between the NTSC and PAL primaries. They're not much different anyway. It's using the wrong matrix for converting to RGB on playback that can make a noticeable difference to the colors.

    As a side note, I found myself learning a little more on this topic recently while adding color conversion to a script. I only mention it here as I wrote a mini essay explaining how color conversion is done, or at least should be done, and why the script works the way it does. It's under "ColorCorrect" in the help file if you'd care to read it.
    Last edited by hello_hello; 11th Oct 2019 at 15:07.
    Quote Quote  
  9. Two things worthy of note here.

    First, there are no bt470bg option for color_trc, but there is for color_primaries and colorspace. What whould you use?

    Second, I've tried a few videos with Handbrake. With HD it sets all three to bt709. For SD it sets primaries as bt407bg/smpte170m depending on the source for both color_primaries and colorspace, however it sets color_trc as bt709?
    Quote Quote  
  10. Originally Posted by ZetaStax View Post
    Two things worthy of note here.

    First, there are no bt470bg option for color_trc, but there is for color_primaries and colorspace. What would you use?
    x264 does. I know nothing about x265, or how they're set when encoding with ffmpeg.

    For x264:
    --colorprim bt470bg --transfer bt470bg --colormatrix bt470bg

    Otherwise as I mentioned in my previous post, don't bother specifying the Primaries or Transfer for SD, or as Handbrake does, use Rec.709 for Primaries & Transfer instead.
    Quote Quote  
  11. For ffmpeg , libx264 it's -x264opts or -x264params . Same with libx265 -x265opts or -x265params .

    e.g.
    Code:
    -x264opts colorprim=bt470bg:transfer=bt470bg:colormatrix=bt470bg
    In handbrake GUI, there is a commandline options section, the syntax might be slightly different IIRC , you don't use -x264opts, but just the key=value
    Quote Quote  
  12. Great, thanks.
    Quote Quote  



Similar Threads