[SNIPPET] HDR detection

All about user-defined episode / movie / file name format expressions
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

[SNIPPET] HDR detection

Post by devster »

As Mediainfo was updated to include HDR detection, this is a snippet to take full advantage of it.
The map currently detects HDR10, HDR10+ and Dolby Vision.

Code: Select all

{
	def _HDRMap = [
		"HDR10": "HDR10",
		"SMPTE ST 2086": "HDR10",
		"SMPTE ST 2094 App 4": "HDR10+",
		"Dolby Vision / SMPTE ST 2086": "Dolby Vision",
		"Dolby Vision / HDR10": "Dolby Vision",
	]
	def vid = video.first()
	allOf
		{ vf }
		{ vc }
		{ 
			String _HDR
			switch (bitdepth) {
				case { it > 8 }:
					_HDR = any
				   		{ vid["HDR_Format_Commercial"] }
				   		{ vid["HDR_Format"] }
				   		{ hdr }
				   		{ null }
						// { vid["HDR_Format/String"] }
						// { vid["HDR_Format_Compatibility"] }
						// following for both HDR10+ (misses compatibility) and Dolby Vision
						// { vid["HDR_Format_Version"] }
						// following only for Dolby Vision
						// { vid["HDR_Format_Profile"] }
						// { vid["HDR_Format_Level"] }
						// { vid["HDR_Format_Settings"] }
					break
				default:
					"$bitdepth-bit"
				break
			}
			// _HDRMap.get(_HDR, _HDR)
			_HDRMap.find { k, v ->
				k =~ _HDR
			}?.value
		}
	.join(" ")
}
Very unsure about the groovy at the end, this bit in particular:

Code: Select all

			_HDRMap.get(_HDR, _HDR)
			// OR
			_HDRMap.find { k, v ->
				k =~ _HDR
			}.value
which seems wonky but works for now.

UPDATE 2019-09-03 -> changed _HDRMap.find{...}.value to _HDRMap.find{...}?.value, should be null if no key is found.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

What possible values does HDR_Format_Commercial in your test cases?

:!: If it can include a / SLASH then I'll need to update {hdr} accordingly to strip them before the result is being used as file path.
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

The field is usually populated except for esoteric formats such as Hybrid Log-Gamma and SL-HDR1.

As corollary, the HDR designation only requires at least 10 bits, colour_primaries BT.2020 and PQ as transfer function (IIRC).
The last field should be available in mediainfo and could be an optional confirmation field.

UPDATE - some examples:

Code: Select all

HDR_Format                       : SMPTE ST 2086
HDR_Format/String                : SMPTE ST 2086, HDR10 compatible
HDR_Format_Commercial            : HDR10
HDR_Format_Compatibility         : HDR10
----------------------------------------
HDR_Format                       : Dolby Vision / SMPTE ST 2086
HDR_Format/String                : Dolby Vision, Version 1.0, dvhe.08.05, BL+RPU / SMPTE ST 2086, HDR10 compatible
HDR_Format_Commercial            : Dolby Vision / HDR10
HDR_Format_Version               : 1.0 /
HDR_Format_Profile               : dvhe.08 /
HDR_Format_Level                 : 05 /
HDR_Format_Settings              : BL+RPU /
HDR_Format_Compatibility         :  / HDR10
----------------------------------------
HDR_Format                       : SMPTE ST 2094 App 4
HDR_Format/String                : SMPTE ST 2094 App 4, Version 0
HDR_Format_Commercial            : SMPTE ST 2094 App 4
HDR_Format_Version               : 0
these are only few test cases, but they should cover HDR10, HDR10+ and Dolby Vision (regardless of profile).
I only work in black and sometimes very, very dark grey. (Batman)
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

Code: Select all

{
	allOf
		{ vf }
		{ vc }
		{
			def _HDRMap = [
				"HDR10": "HDR10",
				"SMPTE ST 2086": "HDR10",
				"SMPTE ST 2094 App 4": "HDR10+",
				"Dolby Vision / SMPTE ST 2086": "Dolby Vision",
				"Dolby Vision / HDR10": "Dolby Vision",
			]
			def vid = video.first()
			if (bitdepth > 8) {
				String _HDR
				switch (vid) {
					case { it.findAll { p -> p =~ /^HDR_/ }.size() > 0 }:
						_HDR = any
							{ vid["HDR_Format_Commercial"] }
							{ vid["HDR_Format"] }
							{ hdr }
							{ null }
							// { vid["HDR_Format/String"] }
							// { vid["HDR_Format_Compatibility"] }
							// following for both HDR10+ (lacks HDR_Format_Compatibility) and Dolby Vision
							// { vid["HDR_Format_Version"] }
							// following only for Dolby Vision
							// { vid["HDR_Format_Profile"] }
							// { vid["HDR_Format_Level"] }
							// { vid["HDR_Format_Settings"] }
						
						_HDRMap.find { k, v ->
						  k =~ _HDR
						}?.value
						break
					case { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:
						"HLG"
						break
					case { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:
						"HDR"
						break
					default:
						"$bitdepth-bit"
						break
				}
			}
		}
	.join(" ")
}
Updated to support HLG HDR format, at least in test cases.
Last edited by devster on 04 Sep 2019, 08:09, edited 1 time in total.
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

OK, I'll make {hdr} yield only Dolby Vision in this case (i.e. the first part before the slash)

Code: Select all

HDR_Format_Commercial            : Dolby Vision / HDR10
:idea: Please read the FAQ and How to Request Help.
mterrill
Posts: 32
Joined: 21 May 2018, 21:08

Re: [SNIPPET] HDR detection

Post by mterrill »

devster wrote: 03 Sep 2019, 22:17
Hi devster, Is there any update to the above code? i.e. updated hrd formats etc? I just want to add the words "HDR10" or "HDR10+" or "Dolby Vision" to the file and folder name....
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

No, sorry, I don't have that many files with those characteristics.
If you have samples I can work on that though.
I only work in black and sometimes very, very dark grey. (Batman)
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

Recently tried to run it and it seems it's no longer working.
In particular it seems it's a Groovy failure on my side, the following bit no longer returns any element:

Code: Select all

{
	def vid = video.first()
	assert vid.findAll { p -> p.key.startsWith("HDR_") }.size() > 0
}
p.key is null now, but the file does have HDR_* fields:

Code: Select all

Video
...
HDR_Format                       : SMPTE ST 2094 App 4
HDR_Format/String                : SMPTE ST 2094 App 4, Version 1, HDR10+ Profile B compatible
HDR_Format_Commercial            : HDR10+
HDR_Format_Version               : 1
HDR_Format_Compatibility         : HDR10+ Profile B / HDR10
...
Any way to filter video mediainfo field names?
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

I'd use the {hdr} binding to check if something is HDR or not:

Code: Select all

any{ hdr }{ 'NO_HDR' }
or just {bitdepth} if you want to be more lenient about what counts as HDR:

Code: Select all

bitdepth >= 10 ? 'HDR' : 'NO_HDR' }
If you do want to just check if a certain MediaInfo property exists, then checking the String representation for a given pattern would be most straight-forward:

Code: Select all

video =~ /\bHDR_/ ? 'HDR' : 'NO_HDR' 
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

The reason I'm using this check is that in the original snippet I then use specific HDR_* properties from MediaInfo to assign specific HDR profiles or names.
The {hdr} binding works but only returns "HDR" when in this case it's an HDR10+ video. Your last snippet works for my use case:

Code: Select all

{
	def _HDRMap = [
		"HDR10": "HDR10",
		... others ...
	]

	def vid = video.first()
	if (bitdepth > 8) {
		switch (vid) {	
		case { vid =~ /\bHDR_/ }:
			_HDR = any
				{ vid["HDR_Format_Commercial"] }
				{ vid["HDR_Format"] }

			_HDRMap.get(_HDR)
			break
		case { it["transfer_characteristics"].findMatch(/HLG/) }:
			"HLG"
			break
		... others ...
		}
	}
}
However, it would be very useful to have a list of all properties that begin with HDR_* (or something else, like colour_* or MasteringDisplay_*)is there a way?
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

devster wrote: 04 Jun 2021, 18:54 However, it would be very useful to have a list of all properties that begin with HDR_* (or something else, like colour_* or MasteringDisplay_*)is there a way?
Well, we could extend the API, but it's not gonna be as straight-forward as just matching properties from the String representation which already works:

Code: Select all

{video[0].toString().matchAll(/(?:HDR|colour|MasteringDisplay)_[^,]+/)}
e.g.

Code: Select all

[HDR_Format, HDR_Format/String, HDR_Format_Commercial, HDR_Format_Compatibility, colour_description_present, colour_description_present_Source, colour_range, colour_range_Source, colour_primaries, colour_primaries_Source, MasteringDisplay_ColorPrimaries, MasteringDisplay_ColorPrimaries_Source, MasteringDisplay_Luminance, MasteringDisplay_Luminance_Source]
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

Updated version:

Code: Select all

{
	def _HDRMap = [
		"HDR10": "HDR10",
		"SMPTE ST 2086": "HDR10",
		"SMPTE ST 2094 App 3": "Advanced HDR",
		"SMPTE ST 2094 App 4": "HDR10+",
		"Dolby Vision / SMPTE ST 2086": "Dolby Vision",
		"Dolby Vision / HDR10": "Dolby Vision",
		"ETSI TS 103 433": "SL-HDR1",
		"SL-HDR1": "SL-HDR1", // , Version 1.0, Parameter-based, constant
		"SL-HDR2": "SL-HDR2", // , Version 0.0, Parameter-based
		"SL-HDR3": "SL-HDR3",
		"Technicolor Advanced HDR": "Technicolor Advanced HDR",
	]
	def vid = video.first()
	if (bitdepth > 8) {
		switch (vid) {
			case { vid =~ /\bHDR_Format_Commercial/ }:
				vid["HDR_Format_Commercial"]
				break
		case { vid =~ /\bHDR_/ }:
			_HDR = any
				{ vid["HDR_Format"] }
				{ vid["HDR_Format/String"] }
			hdr_out = _HDRMap.get(_HDR, _HDR)
			if ( hdr_out.findMatch(/vision/) ) {
				dv_info = allOf
					{ "P" }
					{ vid["HDR_Format_Profile"].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }
					{ "." + vid["HDR_Format_Compatibility"].match(/HDR10|SDR/).replace("HDR10", "1").replace("SDR", "2") }
				.join()
				hdr_out = "$hdr_out $dv_info"
			}
			hdr_out
			break
		 case { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:
			"HLG10" // HLG
			break
		 case { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:
			"HDR10" // PQ10 or HDR
			break
		 default:
			"$bitdepth-bit"
			break
		}
	}
}

                  if (_HDR_out.findMatch(/dolby/)) {
                    more = allOf
                      { vid["HDR_Format_Profile"] }
                      { vid["HDR_Format_Level"] }
                      { vid["HDR_Format_Settings"] }
                      .join(" ")
                    _HDR_out.append(more)
                  }
I only work in black and sometimes very, very dark grey. (Batman)
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: [SNIPPET] HDR detection

Post by jrhessey »

devster wrote: 05 Jun 2021, 21:27 Updated version:

Code: Select all

{
	def _HDRMap = [
		"HDR10": "HDR10",
		"SMPTE ST 2086": "HDR10",
		"SMPTE ST 2094 App 3": "Advanced HDR",
		"SMPTE ST 2094 App 4": "HDR10+",
		"Dolby Vision / SMPTE ST 2086": "Dolby Vision",
		"Dolby Vision / HDR10": "Dolby Vision",
		"ETSI TS 103 433": "SL-HDR1",
		"SL-HDR1": "SL-HDR1", // , Version 1.0, Parameter-based, constant
		"SL-HDR2": "SL-HDR2", // , Version 0.0, Parameter-based
		"SL-HDR3": "SL-HDR3",
		"Technicolor Advanced HDR": "Technicolor Advanced HDR",
	]
	def vid = video.first()
	if (bitdepth > 8) {
		switch (vid) {
			case { vid =~ /\bHDR_Format_Commercial/ }:
				vid["HDR_Format_Commercial"]
				break
		case { vid =~ /\bHDR_/ }:
			_HDR = any
				{ vid["HDR_Format"] }
				{ vid["HDR_Format/String"] }
			hdr_out = _HDRMap.get(_HDR, _HDR)
			if ( hdr_out.findMatch(/vision/) ) {
				dv_info = allOf
					{ "P" }
					{ vid["HDR_Format_Profile"].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }
					{ "." + vid["HDR_Format_Compatibility"].match(/HDR10|SDR/).replace("HDR10", "1").replace("SDR", "2") }
				.join()
				hdr_out = "$hdr_out $dv_info"
			}
			hdr_out
			break
		 case { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:
			"HLG10" // HLG
			break
		 case { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:
			"HDR10" // PQ10 or HDR
			break
		 default:
			"$bitdepth-bit"
			break
		}
	}
}

                  if (_HDR_out.findMatch(/dolby/)) {
                    more = allOf
                      { vid["HDR_Format_Profile"] }
                      { vid["HDR_Format_Level"] }
                      { vid["HDR_Format_Settings"] }
                      .join(" ")
                    _HDR_out.append(more)
                  }
I tried this code and it bombs out at if (_HDR_out.findMatch(/dolby/)) { chunk of code at the bottom. If I remove that section of code, there are no errors. The if color of the code doesn't match the others in the code, If I remove the previous bracket, it matches but still get an error. I'm assuming there is a misplaced bracket somewhere.

Here is the error I get

groovy.lang.MissingPropertyException: No such property: _HDR_out for class: Script58

I am trying out Filebot r8700
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

My bad, it was a poor paste, you can probably remove this entire section:

Code: Select all

                  if (_HDR_out.findMatch(/dolby/)) {
                    more = allOf
                      { vid["HDR_Format_Profile"] }
                      { vid["HDR_Format_Level"] }
                      { vid["HDR_Format_Settings"] }
                      .join(" ")
                    _HDR_out.append(more)
                  }
I only work in black and sometimes very, very dark grey. (Batman)
jrhessey
Posts: 10
Joined: 30 Jun 2021, 14:16

Re: [SNIPPET] HDR detection

Post by jrhessey »

That's what I left out. Thanks!!

How do I skip the last period of my formatting if there is no HDR/DolbyVision? I've attached the code below. If there is no HDR detected it should stop at {ac} then. Thanks for any help!

right now I am getting
Loki - S01E03 - Lamentis.2160p.6ch.x265.EAC3..mkv

Code: Select all

p:/movies/{n.sortName('$2, $1')} ({y} {certification})\{n}.{vf}.{af}.{vc}.{ac}.{
	def _HDRMap = [
		"HDR10": "HDR10",
		"SMPTE ST 2086": "HDR10",
		"SMPTE ST 2094 App 3": "Advanced HDR",
		"SMPTE ST 2094 App 4": "HDR10+",
		"Dolby Vision / SMPTE ST 2086": "Dolby Vision",
		"Dolby Vision / HDR10": "Dolby Vision",
		"ETSI TS 103 433": "SL-HDR1",
		"SL-HDR1": "SL-HDR1", // , Version 1.0, Parameter-based, constant
		"SL-HDR2": "SL-HDR2", // , Version 0.0, Parameter-based
		"SL-HDR3": "SL-HDR3",
		"Technicolor Advanced HDR": "Technicolor Advanced HDR",
	]
	def vid = video.first()
	if (bitdepth > 8) {
		switch (vid) {
			case { vid =~ /\bHDR_Format_Commercial/ }:
				vid["HDR_Format_Commercial"]
				break
		case { vid =~ /\bHDR_/ }:
			_HDR = any
				{ vid["HDR_Format"] }
				{ vid["HDR_Format/String"] }
			hdr_out = _HDRMap.get(_HDR, _HDR)
			if ( hdr_out.findMatch(/vision/) ) {
				dv_info = allOf
					{ "P" }
					{ vid["HDR_Format_Profile"].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }
					{ "." + vid["HDR_Format_Compatibility"].match(/HDR10|SDR/).replace("HDR10", "1").replace("SDR", "2") }
				.join()
				hdr_out = "$hdr_out $dv_info"
			}
			hdr_out
			break
		 case { it["transfer_characteristics"].findMatch(/HLG/) && it["colour_primaries"] == "BT.2020" }:
			"HLG10" // HLG
			break
		 case { it["transfer_characteristics"] == "PQ" && it["colour_primaries"] == "BT.2020" }:
			"HDR10" // PQ10 or HDR
			break
		 default:
			"$bitdepth-bit"
			break
		}
	}
}
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: [SNIPPET] HDR detection

Post by devster »

The way it's written now the dots aren't an option, they're always there.
You should probably rework the format to make them optional.
I only work in black and sometimes very, very dark grey. (Batman)
ZeroByDivide
Posts: 170
Joined: 16 Dec 2014, 01:39

Re: [SNIPPET] HDR detection

Post by ZeroByDivide »

So the snippet above and well the most up to date version of it:

Code: Select all

Map HDRMap = [
    'HDR10': 'HDR10',
    'SMPTE ST 2086': 'HDR10',
    'SMPTE ST 2094 App 3': 'Advanced HDR',
    'SMPTE ST 2094 App 4': 'HDR10+',
    'Dolby Vision / SMPTE ST 2086': 'Dolby Vision',
    'Dolby Vision / HDR10': 'Dolby Vision',
    'ETSI TS 103 433': 'SL-HDR1',
    'SL-HDR1': 'SL-HDR1', // , Version 1.0, Parameter-based, constant
                          // , Version 1.0, Parameter-based, non-constant
    'SL-HDR2': 'SL-HDR2', // , Version 0.0, Parameter-based
    'SL-HDR3': 'SL-HDR3',
    'Technicolor Advanced HDR': 'Technicolor Advanced HDR',
]

Map vid = video.first()

if (bitdepth > 8) {
    switch (vid) {
        case { vid =~ /\bHDR_Format_Commercial/ }:
            vid['HDR_Format_Commercial']
            break

        case { vid =~ /\bHDR_/ }:
            String fHDR = any
                { vid['HDR_Format'] }
                { vid['HDR_Format/String'] }
                // { vid['HDR_Format/String'] }
                // { vid['HDR_Format_Compatibility'] }
                // following for both HDR10+ (misses compatibility) and Dolby Vision
                // { vid['HDR_Format_Version'] }
                // following only for Dolby Vision
                // { vid['HDR_Format_Profile'] }
                // { vid['HDR_Format_Level'] }
                // { vid['HDR_Format_Settings'] }

            hdr_out = HDRMap.get(fHDR, fHDR)
            if (hdr_out.findMatch(/vision/)) {
                dv_info = allOf
                    { 'P' }
                    { vid['HDR_Format_Profile'].match(/[dh][ve][hvca][e13v]\.\d(\d)/) }
                    {
                        '.' + vid['HDR_Format_Compatibility'].match(/HDR10|SDR/)
                            .replace('HDR10', '1').replace('SDR', '2')
                    }
                .join()
                hdr_out = "$hdr_out $dv_info"
            }
            hdr_out
            break
        case { vid['transfer_characteristics'].findMatch(/HLG/) && vid['colour_primaries'] == 'BT.2020' }:
            'HLG10' // HLG
            break
        case { vid['transfer_characteristics'] == 'PQ' && vid['colour_primaries'] == 'BT.2020' }:
            'HDR10' // PQ10 or HDR
            break
        default:
            "$bitdepth-bit"
            break
    }
}
has some problems when it comes to certain videos it seems.. I've ran into two so far and it seems to be due to the way "HDR_Format_Commercial" does its values. Two different files names for example:

"Elemental.2023.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-FLUX" ends up turning into "Elemental (2023) [2160p HEVC HDR10\HDR10+ - 5.1+15obj E-AC-3 JOC+Atmos Eng - WEB-DL]-FLUX.mkv"

and

"Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG" turned into "Avatar - The Way of Water (2022) - [2160p HEVC HDR10\HDR10 - 5.1+15obj E-AC-3 JOC+Atmos Eng - MA WEB-DL]-CMRG.mkv"

both end up with something along the lines of "HDR10\HDR10" and "HDR10\HDR10+" (I can't remember if "avatar the way of water did it with a "+" on the second "HDR10" or not as well since I deleted it so long ago) which in turns messes up file path making the first part up to the "\" a folder while everything after it is the name of the file.
ZeroByDivide
Posts: 170
Joined: 16 Dec 2014, 01:39

Re: [SNIPPET] HDR detection

Post by ZeroByDivide »

@rednoah got any ideas on how to fix the above exactly?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

Sorry, the code is too complicated and I don't have your test files. If you have a specific test case then I could look into that. Otherwise I can only tell you that if you get "HDR10\HDR10" then that's the return value of the code at hand, but you'd have to debug the code step by step to find out why. You can launch with a console and add println statements to see intermediate values.


:idea: I did try with one HDR file though and I'm getting HDR10 based on this code path:

Groovy: Select all

        case { vid =~ /\bHDR_Format_Commercial/ }:
            vid['HDR_Format_Commercial']
            break
:idea: Please read the FAQ and How to Request Help.
ZeroByDivide
Posts: 170
Joined: 16 Dec 2014, 01:39

Re: [SNIPPET] HDR detection

Post by ZeroByDivide »

rednoah wrote: 19 Aug 2023, 17:16 Sorry, the code is too complicated and I don't have your test files. If you have a specific test case then I could look into that. Otherwise I can only tell you that if you get "HDR10\HDR10" then that's the return value of the code at hand, but you'd have to debug the code step by step to find out why. You can launch with a console and add println statements to see intermediate values.


:idea: I did try with one HDR file though and I'm getting HDR10 based on this code path:

Groovy: Select all

        case { vid =~ /\bHDR_Format_Commercial/ }:
            vid['HDR_Format_Commercial']
            break

The thing I've noticed it the most on was video files that have both DV and HDR10 in their file names (and not just HDR10) like

Code: Select all

Avatar.The.Way.of.Water.2022.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR10.HEVC-CMRG
and

Code: Select all

Elemental.2023.2160p.WEB-DL.DDP5.1.Atmos.DV.HDR.H.265-FLUX
as so far that has been the two cases where I have seen this happen, but what kind of test files do you exactly need? I might be able to provide them if need be.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

I'd start by looking that MediaInfo table to see what values your custom format is working with. Then I would rewrite your format step by step to find out which code path produces the undesired return value. Running tests is much easier for you because you have a sample file to test with.
:idea: Please read the FAQ and How to Request Help.
ZeroByDivide
Posts: 170
Joined: 16 Dec 2014, 01:39

Re: [SNIPPET] HDR detection

Post by ZeroByDivide »

rednoah wrote: 20 Aug 2023, 03:46 I'd start by looking that MediaInfo table to see what values your custom format is working with. Then I would rewrite your format step by step to find out which code path produces the undesired return value. Running tests is much easier for you because you have a sample file to test with.
damn I completely forgot about the mediaInfo table, I just kept looking at the Movie Bindings table instead and trying to figure things out. I took a look into mediainfo table and the HDR_Format_Commercial for both my examples came back as

Code: Select all

HDR10 / HDR10+
so guess I'm just going to do a simple

Code: Select all

.replace('HDR10 / HDR10+', 'Dolby Vision')
(not sure if this should be HDR10 or Dolby Vision since the examples I'm using have both dolby vision and HDR10) on

Code: Select all

        case { vid =~ /\bHDR_Format_Commercial/ }:
            vid['HDR_Format_Commercial'].replace('HDR10 / HDR10+', 'Dolby Vision')
            break
when before I was always trying things like

Code: Select all

.replace('/HDR10+', '')
or trying other various regexes and such in various parts of my code when I was trying to fix this and just getting no where.

btw you did ask devster back in 2019 if this was a possibility here viewtopic.php?p=45654#p45654 (same thread we are in currently but further up on the page) but it seems he didn't have any examples that produced

Code: Select all

HDR10 / HDR10+
at the time.

mediainfo for both my examples:

Code: Select all

HDR_Format                       : Dolby Vision / SMPTE ST 2094 App 4
HDR_Format/String                : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2094 App 4, Version 1, HDR10+ Profile A compatible
HDR_Format_Commercial            : HDR10 / HDR10+
HDR_Format_Version               : 1.0 / 1
HDR_Format_Profile               : dvhe.08 /
HDR_Format_Level                 : 06 /
HDR_Format_Settings              : BL+RPU /
HDR_Format_Compatibility         : HDR10 / HDR10+ Profile A
The only part that changes between both of my examples is the "HDR_Format_Level" one being at a 06 and one being at a 07
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [SNIPPET] HDR detection

Post by rednoah »

Yep, if you have / in the property value then you need to take care of that one way or another, otherwise FileBot will do what it is told verbatim, since FileBot can't really know which / is on purpose and which / is accidental.


e.g. split by / and pick the last element:

Format: Select all

{ 'HDR10 / HDR10+'.split('/').last().trim() }


:idea: FileBot does not implicitly strip / away because this is a value you are working with, so it'd be very unexpected if you see a / b / c in the MediaInfo table but somehow get a b c as property value with no way of knowing what the actual original value should have been.



:idea: What does HDR10 / HDR10+ indicate? I don't know. My best guess is that a new HDR10+ format was introduced that allows for HDR10+ but also HDR10 backwards-compatibility. Dolby Vision content has the problem that it can't be played (can but colors are off) on most devices at all.
:idea: Please read the FAQ and How to Request Help.
Post Reply