{"id":116,"date":"2009-10-02T21:26:01","date_gmt":"2009-10-02T20:26:01","guid":{"rendered":"http:\/\/www.mod16.org\/hurfdurf\/?p=116"},"modified":"2011-05-31T21:34:16","modified_gmt":"2011-05-31T20:34:16","slug":"using-x264s-color-coefficient-flagging-properly","status":"publish","type":"post","link":"https:\/\/mod16.org\/hurfdurf\/?p=116","title":{"rendered":"Using x264&#8217;s color coefficient flagging properly"},"content":{"rendered":"<p>OK so you have a HD transport stream, you encode it and don&#8217;t use colormatrix() in Avisynth because you realized back in 2008 or so that doing so was kind of a dumb idea. Now you want to tell decoders what color coefficients the video uses so it will (hopefully) look correct everywhere, even if you downscale it so ffdshow&#8217;s\/Haali&#8217;s resolution-based autodetection fails. What to do?<\/p>\n<p>The answer to this is obviously &#8220;flag it in the h264 bitstream&#8221; (if you&#8217;re one of those scrubs who still use Xvid just ignore the issue, nobody cares about Xvid anymore). The problem with this answer is that nobody understand what the hell vui.txt actually means. However, in some recent conversation in #darkhold Kovensky linked to a paste where pengvado\/akupenguin explained it in more detail.<\/p>\n<p>More specifically:<\/p>\n<ul>\n<li><strong>&#8211;colormatrix<\/strong> specifies what coefficients are used when converting YUV to RGB. This is the one you want to use.<\/li>\n<li><strong>&#8211;colorprim<\/strong> specifies what color primaries (see for example <a href=\"http:\/\/en.wikipedia.org\/wiki\/SRGB\">the Wikipedia page about sRGB<\/a>) the RGB uses. Setting this properly most likely requires knowledge of the studio equipment used to master the stream and\/or its settings, so just leave it undefined. No one without a color calibrated monitor would ever notice or care, even if decoders\/renderers actually supported this.<\/li>\n<li><strong>&#8211;transfer<\/strong> specifies the gamma curve used for the RGB. Like &#8211;colorprim, setting this correctly probably requires knowledge you don&#8217;t have, so don&#8217;t set it at all. Again, only people with calibrated studio monitors will ever notice or care.<\/li>\n<\/ul>\n<p><strong>TL;DR:<\/strong> Use <tt>--colormatrix bt709<\/tt> if your source is a HD transport stream; <tt>--colormatrix bt470bg<\/tt> if it is an SD transport stream.<\/p>\n<h3>EDIT 2011-05-31<\/h3>\n<p>JEEB informs me all ARIB broadcasts (i.e. Japanese ones) are always supposed to use Rec.709 regardless of resolution. So you should always use bt709 there.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OK so you have a HD transport stream, you encode it and don&#8217;t use colormatrix() in Avisynth because you realized back in 2008 or so that doing so was kind of a dumb idea. Now you want to tell decoders what color coefficients the video uses so it will (hopefully) look correct everywhere, even if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-encoding"],"_links":{"self":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=116"}],"version-history":[{"count":4,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":182,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions\/182"}],"wp:attachment":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}