I want to tag video as explicitly bt.601, rather than "unspecified". I know players typically choose bt.601 as the default for videos less than 1280 pixels wide, but I want to make it explicit that bt.601 is the correct colour matrix for a video.
The sticking point is that there is no bt601
option for ffmpeg or libx264, only bt709 and some others.
I have some videos that were downscaled from HD, and are still in bt.709, but aren't tagged properly. So when I watch a video, I sometimes have to manually toggle my player to bt.709. Tagging explicitly as bt.601 will communicate to future viewers (e.g. myself) that it's definitely bt.601, and not a mis-tagged bt.709 video, when I look at it with mediainfo
.
Another use-case for this would be if you upscaled a bt.601 video to 1280 or higher without doing a colormatrix conversion (using -vf colormatrix
), players would incorrectly assume bt.709 if you left the color information unspecified.
FFMpeg's colormatrix
video filter does support bt601
as an input or output color matrix, but doesn't also set tags. (Since it doesn't have the side-effect of setting ffmpeg's color options, it refuses to even operate with src and dest the same, like -vf colormatrix=bt601:bt601
.)
ffmpg in -color_primaries bt709 -color_trc bt709 -colorspace bt709 out
will tag the output video as using bt.709 for yuv<->rgb. The tags end up inside the video bitstream itself, not just in the container (since this is seems to be a codec-specific thing, not a container thing, for mp4 and mkv containers at least).
e.g. mediainfo
output:
Complete name : out.mkv
...
Writing application : Lavf57.14.100
Writing library : Lavf57.14.100
Video
ID : 1
Format : AVC
...
Writing library : x264 core 148 r2638+4 afcf21c
Encoding settings : cabac=1 / ref=8 / ...
Language : English
Default : Yes
Forced : No
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
So bt.709 is easy to tag. The problem is, I don't see bt.601 anywhere. Is one of other names an alias for it, or is there really no way to specify it explicitly?
x264 --fullhelp output:
--colorprim <string> Specify color primaries ["undef"]
- undef, bt709, bt470m, bt470bg, smpte170m,
smpte240m, film, bt2020
--transfer <string> Specify transfer characteristics ["undef"]
- undef, bt709, bt470m, bt470bg, smpte170m,
smpte240m, linear, log100, log316,
iec61966-2-4, bt1361e, iec61966-2-1,
bt2020-10, bt2020-12
--colormatrix <string> Specify color matrix setting ["???"]
- undef, bt709, fcc, bt470bg, smpte170m,
smpte240m, GBR, YCgCo, bt2020nc, bt2020c
ffmpeg -h full
shows the same set of options for its color options, which ffmpeg's -c:v libx264
video codec passes on to x264. Is any of these an alias for bt.601, or have a numerically equivalent colour matrix?
-color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m
).