Log in

View Full Version : [FFMPEG] Colorspace, matrix...


rgr
30th July 2024, 17:26
Is this how it's supposed to be? Ffmpeg reports transfer_characteristics as "smpte170m," while MediaInfo reports "BT.601" I associate SMPTE170M with the NTSC system, but this is a PAL recording (captured from HDMI).


FFMPEG:

Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt470bg/bt470bg/smpte170m), 720x576 [SAR 12:11 DAR 15:11], 12051 kb/s, 50 fps, 50 tbr, 10k tbn (default)

MediaInfo:

Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main@L3@Main
Codec ID : hvc1
Codec ID/Info : High Efficiency Video Coding
Duration : 1 h 29 min
Bit rate : 12.1 Mb/s
Maximum bit rate : 48.9 Mb/s
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 4:3
Frame rate mode : Variable
Frame rate : 50.000 FPS
Minimum frame rate : 42.373 FPS
Maximum frame rate : 60.976 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.581
Stream size : 7.55 GiB (99%)
Color range : Limited
Color primaries : BT.601 PAL
Transfer characteristics : BT.601
Matrix coefficients : BT.470 System B/G
Codec configuration box : hvcC

poisondeathray
30th July 2024, 18:28
Functionally it does not matter for Transfer - because BT.601, smpte170m, 709 , 2020 have the same values for the transfer curve. Look at Table E.4 in the H265 document

FranceBB
31st July 2024, 13:22
Is this how it's supposed to be? Ffmpeg reports transfer_characteristics as "smpte170m," while MediaInfo reports "BT.601" I associate SMPTE170M with the NTSC system, but this is a PAL recording (captured from HDMI).

FFMpeg is actually right. Mediainfo is just simplifying by translating the value of both gamma28 and smpte170m to BT601. I mean, they're both BT601 after all, but you're right in saying that smpte170m is for NTSC, in fact BT601 PAL is gamma28. I'm not sure what you're using to capture the stream, nor if you're capturing the stream directly in H.265 and/if you have some room for manoeuvre, but in case:

FFMpeg BT601 PAL

-color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg

FFMpeg BT601 NTSC

-color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m





x262/x264/x265 BT601 PAL

--colormatrix bt470bg --transfer bt470bg --colorprim bt470bg


x262/x264/x265 BT601 NTSC

--colormatrix smpte170m --transfer smpte170m --colorprim smpte170m



worst case scenario, just capture in v210 lossless and then re-encode with x265 with the right metadata. ;)

Corn Xin
6th August 2024, 15:07
Is this how it's supposed to be? Ffmpeg reports transfer_characteristics as "smpte170m," while MediaInfo reports "BT.601" I associate SMPTE170M with the NTSC system, but this is a PAL recording (captured from HDMI).


FFMPEG:

Stream #0:0[0x1](und): Video: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt470bg/bt470bg/smpte170m), 720x576 [SAR 12:11 DAR 15:11], 12051 kb/s, 50 fps, 50 tbr, 10k tbn (default)

MediaInfo:

Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main@L3@Main
Codec ID : hvc1
Codec ID/Info : High Efficiency Video Coding
Duration : 1 h 29 min
Bit rate : 12.1 Mb/s
Maximum bit rate : 48.9 Mb/s
Width : 720 pixels
Height : 576 pixels
Display aspect ratio : 4:3
Frame rate mode : Variable
Frame rate : 50.000 FPS
Minimum frame rate : 42.373 FPS
Maximum frame rate : 60.976 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Bits/(Pixel*Frame) : 0.581
Stream size : 7.55 GiB (99%)
Color range : Limited
Color primaries : BT.601 PAL
Transfer characteristics : BT.601
Matrix coefficients : BT.470 System B/G
Codec configuration box : hvcC

Hey rgr, that's weird! FFmpeg says smpte170m but MediaInfo says BT.601. Since it's a PAL recording, BT.601 makes more sense. Maybe it's just how each tool reports color space and matrix coefficients?

FranceBB
6th August 2024, 23:22
Maybe it's just how each tool reports color space and matrix coefficients?

Yes, it is a matter of what each tool is reporting it, but at the same time ffprobe is the one reporting the actual value while Mediainfo is just making things easier for the reader. That being said, the actual value is wrong as it's BT601 NTSC as transfer characteristics but BT601 PAL for matrix and primaries, so it's wrong.
As I was saying, unlike BT709 and BT2020 where everything is the same for both PAL and NTSC, there's a difference for BT601. If anything, one could argue that there's nothing like a BT601 transfer characteristics: there's gamma28 which is for PAL and smpte170m which is for NTSC. They both refer to BT601 but they have slightly different values.

In RGB we have an X and a Y coordinate for each component so that they can be expressed as:

(Xr, Yr)
(Xg, Yg)
(Xb, Yb)

For gamma28 (BT601 PAL) those are:

(0.640, 0.330)
(0.290, 0.600)
(0.150, 0.060)

For smpte170m (BT601 NTSC) those are:

(0.630, 0.340)
(0.310, 0.595)
(0.155, 0.070)

As you can see they're very close but slightly different.


Now the reason why you just see BT601 in Mediainfo is that it has a mapping where both gamma28 and smpte170m (i.e the actual values of the transfer characteristics) are mapped to the string BT601. Again, this is to make things easier for users, while ffprobe is just showing the actual value. It's a bit like when we have arib-std-b67 or smpte2084 in the transfer characteristics in ffprobe while Mediainfo shows HLG and PQ respectively as it's mapping the strings.

huhn
8th August 2024, 21:25
if media info really shows bt601 for bt450 which has a transfer function of 2.2 or 2.8 as said before it is utterly wrong and should be changed.

showing smapte170m as bt601 doesn't do damage both refer to the b709 transfer which is not used because it is an encoding transfer function.