Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st March 2022, 21:29   #1  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Over-saturated dashcam video: Patch HEVC colorimetry header?

I got a request from an owner of a Vantrue X4S dashcam. He noticed that videos recorded by this camera appear over-saturated when downloaded to the PC. But they look suitable in the Vantrue mobile app. I checked a file (HEVC and AAC in MP4) with MediaInfo and noticed that the colorimetry is flagged as full scale BT.709; so I guess the "full scale" flag might be created wrong by the camera, hence media players respecting this flag expand the chrominance too wide, while the Vantrue app ignores it.

So I wonder: Is there any tool which is able to patch a HEVC video header in a way that the colorimetry gets changed to limited scale?

Or can you imagine a different reason?


Code:
Count                           : 331
Count of stream of this kind    : 1
Kind of stream                  : General
Stream identifier               : 0
Count of video streams          : 1
Count of audio streams          : 1
Video_Format_List               : HEVC
Video_Format_WithHint_List      : HEVC
Codecs Video                    : HEVC
Video_Language_List             : en
Audio_Format_List               : AAC LC
Audio_Format_WithHint_List      : AAC LC
Audio codecs                    : AAC LC
Audio_Language_List             : en
Complete name                   : F:\Downloads\20220331_155500_0213_N_A.MP4
Folder name                     : F:\Downloads
File name extension             : 20220331_155500_0213_N_A.MP4
File name                       : 20220331_155500_0213_N_A
File extension                  : MP4
Format                          : MPEG-4
Format/Extensions usually used  : braw mov mp4 m4v m4a m4b m4p m4r 3ga 3gpa 3gpp 3gp 3gpp2 3g2 k3g jpm jpx mqv ismv isma ismt f4a f4b f4v
Commercial name                 : MPEG-4
Format profile                  : Base Media / Version 2
Internet media type             : video/mp4
Codec ID                        : mp42
Codec ID                        : mp42 (isom/avc1/mp42)
Codec ID/Url                    : http://www.apple.com/quicktime/download/standalone.html
CodecID_Compatible              : isom/avc1/mp42
File size                       : 111396516
File size                       : 106 MiB
File size                       : 106.2 MiB
Duration                        : 60000
Duration                        : 1mn 0s
Duration                        : 1mn 0s 0ms
Duration                        : 00:01:00.000
Duration                        : 00:01:00:00
Duration                        : 00:01:00.000 (00:01:00:00)
Overall bit rate mode           : VBR
Overall bit rate                : 14852869
Overall bit rate                : 14.9 Mbps
Frame rate                      : 30.000
Frame rate                      : 30.000 fps
Frame count                     : 1800
Stream size                     : 3394340
Stream size                     : 3.24 MiB (3%)
Stream size                     : 3 MiB
Stream size                     : 3.2 MiB
Stream size                     : 3.24 MiB
Stream size                     : 3.237 MiB
Proportion of this stream       : 0.03047
HeaderSize                      : 31716
DataSize                        : 111340648
FooterSize                      : 24152
IsStreamable                    : No
Encoded date                    : UTC 2022-03-31 15:56:00
Tagged date                     : UTC 2022-03-31 15:56:00
File creation date              : UTC 2022-03-31 16:42:20.280
File creation date (local)      : 2022-03-31 18:42:20.280
File last modification date     : UTC 2022-03-31 16:42:26.106
File last modification date (local): 2022-03-31 18:42:26.106

Video

Count                           : 378
Count of stream of this kind    : 1
Kind of stream                  : Video
Stream identifier               : 0
StreamOrder                     : 0
ID                              : 1
Format                          : HEVC
Format/Info                     : High Efficiency Video Coding
Format/Url                      : http://www.itu.int
Commercial name                 : HEVC
Format profile                  : Main@L5@High
Internet media type             : video/H265
Codec ID                        : hvc1
Codec ID/Info                   : High Efficiency Video Coding
Codec ID/Url                    : http://www.itu.int/
Duration                        : 60000
Duration                        : 1mn 0s
Duration                        : 1mn 0s 0ms
Duration                        : 00:01:00.000
Duration                        : 00:01:00:00
Duration                        : 00:01:00.000 (00:01:00:00)
Bit rate                        : 14336320
Bit rate                        : 14.3 Mbps
Width                           : 2560
Width                           : 2560 pixel
Height                          : 1440
Height                          : 1440 pixel
Sampled_Width                   : 2560
Sampled_Height                  : 1440
Pixel aspect ratio              : 1.000
Display aspect ratio            : 1.778
Display aspect ratio            : 16:9
Rotation                        : 0.000
Frame rate mode                 : CFR
Frame rate                      : 30.000
Frame rate                      : 30.000 fps
Frame count                     : 1800
Color space                     : YUV
Chroma subsampling              : 4:2:0
Bit depth                       : 8
Bit depth                       : 8 bit
Bits/(Pixel*Frame)              : 0.130
Stream size                     : 107522398
Stream size                     : 103 MiB (97%)
Stream size                     : 103 MiB
Stream size                     : 102.5 MiB
Proportion of this stream       : 0.96522
Language                        : English
Language                        : eng
Encoded date                    : UTC 2022-03-31 15:56:00
Tagged date                     : UTC 2022-03-31 15:56:00
colour_description_present      : Yes
colour_description_present_Source: Stream
Color range                     : Full
colour_range_Source             : Stream
Color primaries                 : BT.709
colour_primaries_Source         : Stream
Transfer characteristics        : BT.709
transfer_characteristics_Source : Stream
Matrix coefficients             : BT.709
matrix_coefficients_Source      : Stream
CodecConfigurationBox           : hvcC

Audio

Count                           : 281
Count of stream of this kind    : 1
Kind of stream                  : Audio
Stream identifier               : 0
StreamOrder                     : 1
ID                              : 2
Format                          : AAC
Format                          : AAC LC
Format/Info                     : Advanced Audio Codec Low Complexity
Commercial name                 : AAC
Format_AdditionalFeatures       : LC
Codec ID                        : mp4a-40-2
Duration                        : 59968
Duration                        : 59s 968ms
Duration                        : 00:00:59.968
Duration                        : 00:00:58:09
Duration                        : 00:00:59.968 (00:00:58:09)
Bit rate mode                   : VBR
Bit rate                        : 64005
Bit rate                        : 64.0 Kbps
Channel(s)                      : 1
Channel(s)                      : 1 channel
Channel positions               : Front: C
Channel positions               : 1/0/0
Channel layout                  : C
Samples per frame               : 1024
Sampling rate                   : 16000
Sampling rate                   : 16.0 KHz
Samples count                   : 959488
Frame rate                      : 15.625
Frame rate                      : 15.625 fps (1024 SPF)
Frame count                     : 937
Compression mode                : Lossy
Stream size                     : 479778
Stream size                     : 469 KiB (0%)
Stream size                     : 469 KiB
Stream size                     : 468.5 KiB
Proportion of this stream       : 0.00431
Language                        : English
Language                        : eng
Encoded date                    : UTC 2022-03-31 15:56:00
Tagged date                     : UTC 2022-03-31 15:56:00
mdhd_Duration                   : 59968
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 1st April 2022, 00:42   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,346
Quote:
Originally Posted by LigH View Post

So I wonder: Is there any tool which is able to patch a HEVC video header in a way that the colorimetry gets changed to limited scale?
ffmpeg

https://www.ffmpeg.org/ffmpeg-bitstr...c_005fmetadata

eg.

Code:
ffmpeg -i input.mp4 -bsf:v hevc_metadata=video_full_range_flag=0 -c copy output.mp4
poisondeathray is offline   Reply With Quote
Old 1st April 2022, 08:43   #3  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753


Unfortunately, the result is even the opposite of my expectation, I must have confused the meaning. When the material is flagged as "limited range", it is decoded to a higher contrast, which makes the over-saturation even more prominent.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 1st April 2022, 23:52   #4  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Can't you trim a tiny bit and send it to us?
FranceBB is offline   Reply With Quote
Old 4th April 2022, 07:31   #5  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Here you are. ~8 MB, 5 sec. Most obvious for the bright red car to the left of the junction, but also the traffic signs, construction lights, and yellow road marking.

I am pretty sure that the main fix requires a firmware update. The camera, unfortunately, has no saturation tuning, I was told by the owner.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 4th April 2022, 10:51   #6  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by LigH View Post
Most obvious for the bright red car to the left of the junction, but also the traffic signs, construction lights, and yellow road marking.
The thing is that the video metadata says that it's full range and indeed it is:




So changing the tag will do nothing but harm, 'cause it's not limited, it's indeed Full Range.

Why the client is seeing it correctly on his reference monitor is a mystery to me, honestly.
I'm afraid there's nothing you can do without re-encoding.

If you're willing to re-encode, then Levels can be used to go to Limited TV Range:

Code:
Levels(0, 1, 255, 16, 235, coring=false)


and if you want to go a bit further:

Code:
Levels(0, 1, 255, 16, 235, coring=false)
tweak(sat=0.75, dither=true)
RangeY(a=16, b=235, ao=16, bo=235, g=1.0, mode=1, bitdepth=8)
RangeUV(au=16, bu=240, aou=16, bou=240, av=16, bv=240, aov=16, bov=240, mode=1, bitdepth=8)
FranceBB is offline   Reply With Quote
Old 4th April 2022, 13:47   #7  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,997
Or similar, something like
Code:
SmoothTweak(contrast=0.95,saturation=0.75,HQ=true,Limiter=False)
mergechroma(SmoothLevels(input_low=0,gamma=1.0,input_high=255,output_low=16,output_high=235,HQ=true, Limiter=0),last) #level shift with chroma copyback

Last edited by Sharc; 4th April 2022 at 19:55.
Sharc is offline   Reply With Quote
Old 4th April 2022, 21:32   #8  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
It's quite saturated, but this is just how particular camera reacts on those vibrant colors (just poor processing).
It just clips Rec.709 gamut, so needs some adjustments- gamut compression.
Even pro cameras sometimes have problems with saturated colors.

Last edited by kolak; 4th April 2022 at 21:37.
kolak is offline   Reply With Quote
Old 5th April 2022, 07:47   #9  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,753
Quote:
Originally Posted by FranceBB View Post
Why the client is seeing it correctly on his reference monitor is a mystery to me, honestly.
I'm afraid there's nothing you can do without re-encoding.
I can only guess that the company knows about the encoding mistake and compensates for that in their own mobile playback app. So if the owner offers dashcam clips to other YouTube channel hosts for compilations, he better tells them: Beware, my clips are over-saturated, you better reduce the saturation of my clips in your NLE.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 5th April 2022, 08:12   #10  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by LigH View Post
Beware, my clips are over-saturated, you better reduce the saturation of my clips in your NLE.
They're over saturated AND Full Range and we all know that delivering full range contents to YouTube is never a good idea, so they should:

1) Convert to Limited TV Range
2) Desaturate

But yeah a NLE like AVID, Davinci Resolve, Premiere etc can do that fairly easily.
In AVID it's right click on the masterclip, source settings, color adapter: Levels scaling (full range to video levels).



Then they can use the color correction panel to have some better adjustments or just drag and drop the "safe color limiter" filter to the sequence and call it a day.
FranceBB is offline   Reply With Quote
Old 5th April 2022, 12:41   #11  |  Link
kolak
Registered User
 
Join Date: Nov 2004
Location: Poland
Posts: 2,843
If your app properly follows headers then levels should not be a problem. Not sure how many do- probably not many
Full level recordings are not uncommon (you gain a lot, specially for 8its). Problem is that so many apps are hardcoded and expect limited levels for YUV.
YUV can be full levels and it's not against any rule or spec.
If given format has specific flag and allows for limited/full levels then there is no reason not to use it if needed.
It's just shortcuts in many apps which make it problematic and some wild assumption that YUV=limited levels.
With some NLEs you get to very bad situations as you can't easily overwrite levels, eg. Premiere.

Last edited by kolak; 5th April 2022 at 12:54.
kolak is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:03.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.