mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
26.67k stars 2.83k forks source link

Dolby Vision property #10390

Open Doofussy2 opened 1 year ago

Doofussy2 commented 1 year ago

I want to make an auto-profile exclusively for Dolby Vision, but I haven't found a property that would allow this. Is there such a property?

haasn commented 1 year ago

Not currently. I remember looking into this but I don't remember exactly what the conclusion was. Some things are unfortunately very hard to support as properties because DoVi records are attached to individual frames, rather than the stream.

However, the config record is present at the stream-level, so we should be able to make a property for its presence or absence. I don't remember why I didn't.

dyphire commented 1 year ago

Not currently. I remember looking into this but I don't remember exactly what the conclusion was. Some things are unfortunately very hard to support as properties because DoVi records are attached to individual frames, rather than the stream.

However, the config record is present at the stream-level, so we should be able to make a property for its presence or absence. I don't remember why I didn't.

Maybe we just need to create a property for the profile of Dolby Vision, such as dolbyvision-profile.

Doofussy2 commented 1 year ago

The reason I need the profile at all, is because when running Windows in HDR, Dolby Vision is way too bright (low target-peak) and I have to specify the target-peak for it to display correctly. Presently, DoVi is initially read as bt.709., so I have a profile for bt.709 with target-peak=1000 specified, which corrects it. But this in turn, makes the SDR media too dark. Still watchable, but obviously not correct. Regardless of this I would still prefer to be able to make a profile for DoVi.

mdannp commented 1 year ago

I am using this, which works as long as filenames are named accordingly:

[DV]
profile-desc=DV
profile-cond=filename ~= nil and (filename:upper():match"[.]DV[.]" ~= nil or filename:upper():match"[.]DOVI[.]" ~= nil) and p["video-params/gamma"]~=nil and p["video-params/gamma"]~="pq" 
# .. your profile settings

but I agree: a property to tell us exactly would be nice

dyphire commented 10 months ago

After this commit https://github.com/mpv-player/mpv/commit/3cf71fd7c7f5d4052b67ebdf11ff416a9beffbeb, the following auto-profile can be used to the video of Dolby Vision Profile 5.

Edit: This is an incorrect use case.

dyphire commented 10 months ago

SDR video also causes this profile to be triggered.

Indeed, it's confusing.

Doofussy2 commented 10 months ago

There's nothing in that commit that uniquely identifies Dolby vision metadata. It's for HDR10 and HDR10+

dyphire commented 10 months ago

hdr-metadata/max-luma and hdr-metadata/max-pq-y should be able to be used to differentiate between HDR (including DVP5)/SDR video, which is the main use case for the DV attribute, but for some reason this one has no effect.

[HDR]
profile-cond=p["hdr-metadata/max-luma"] > 203 or p[" hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
target-trc=pq
target-prim=bt.2020

I attempted to use this sub property of hdr-metadata/max-pq-y for auto-profile at the beginning, but it not work.

Doofussy2 commented 10 months ago

hdr-metadata/max-luma and hdr-metadata/max-pq-y should be able to be used to differentiate between HDR (including DVP5)/SDR video, which is the main use case for the DV attribute, but for some reason this one has no effect.

[HDR]
profile-cond=p["hdr-metadata/max-luma"] > 203 or p[" hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
target-trc=pq
target-prim=bt.2020

I attempted to use this sub property of hdr-metadata/max-pq-y for auto-profile at the beginning, but it not work.

That would include all HDR. I am looking for a property that will exclusively apply to Dolby Vision.

haasn commented 10 months ago

hdr-metadata/max-luma and hdr-metadata/max-pq-y should be able to be used to differentiate between HDR (including DVP5)/SDR video, which is the main use case for the DV attribute, but for some reason this one has no effect.

[HDR]
profile-cond=p["hdr-metadata/max-luma"] > 203 or p[" hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
target-trc=pq
target-prim=bt.2020

Can somebody explain to me what the point of this profile is supposed to be? Why would you need to distinguish between HDR and SDR profiles? If you override target-trc/target-prim without actually enabling HDR mode, output will just be wrong. If you are enabling HDR mode, it should already have set the right output colorspace for you.

haasn commented 10 months ago

hdr-metadata/max-luma and hdr-metadata/max-pq-y should be able to be used to differentiate between HDR (including DVP5)/SDR video, which is the main use case for the DV attribute, but for some reason this one has no effect.

[HDR]
profile-cond=p["hdr-metadata/max-luma"] > 203 or p[" hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
target-trc=pq
target-prim=bt.2020

Can somebody explain to me what the point of this profile is supposed to be? Why would you need to distinguish between HDR and SDR profiles? If you override target-trc/target-prim without actually enabling HDR mode, output will just be wrong. If you are enabling HDR mode, it should already have set the right output colorspace for you.

The goal is to output HDR video in HDR mode and output SDR video in SDR mode, mainly to address the DoVi P5 trope. I've set target-colorspace-hint=yes before this profile, so it won't cause wacky colors

Ah, so it's a work-around for --target-colorspace-hint not taking into account DV metadata? Then that should be fixed instead of hacking around it with properties. Incidentally, this is the same fix as https://github.com/mpv-player/mpv/issues/12221#issuecomment-1695977524

Doofussy2 commented 10 months ago

My request is specifically for Dolby Vision. The reason is, in my case the tone mapped result is too bright, and I want to adjust it.

dyphire commented 10 months ago

After some experimentation, I've found that these properties are not available when the video is not playing, thus causing the return value to always be nil, so it may be necessary to have the conditional profile delay loading. I think a lua script is needed instead of a profile.

I have an idea to make it work properly.

[DoVi-profile 5]
profile-cond=p["estimated-vf-fps"] > 1 and p["video-params/gamma"] == "bt.1886" and p["hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
# ... your profile settings
dyphire commented 10 months ago

hdr-metadata/max-luma and hdr-metadata/max-pq-y should be able to be used to differentiate between HDR (including DVP5)/SDR video, which is the main use case for the DV attribute, but for some reason this one has no effect.

[HDR]
profile-cond=p["hdr-metadata/max-luma"] > 203 or p[" hdr-metadata/max-pq-y"] ~= nil
profile-restore=copy
target-trc=pq
target-prim=bt.2020

Can somebody explain to me what the point of this profile is supposed to be? Why would you need to distinguish between HDR and SDR profiles? If you override target-trc/target-prim without actually enabling HDR mode, output will just be wrong. If you are enabling HDR mode, it should already have set the right output colorspace for you.

The goal is to output HDR video in HDR mode and output SDR video in SDR mode, mainly to address the DoVi P5 trope. I've set target-colorspace-hint=yes before this profile, so it won't cause wacky colors

Ah, so it's a work-around for --target-colorspace-hint not taking into account DV metadata? Then that should be fixed instead of hacking around it with properties. Incidentally, this is the same fix as #12221 (comment)

Yes, fixing it is much better than using this hacker method.

kasper93 commented 9 months ago

I briefly was thinking about it. I'm reluctant of adding any DV specific property or even reference the name of it. We use PQ(Y) from it and that's about it.

If there are issues with DV they need to be fixed. I don't see why profile should distinguish between HDR10+, DV or even peak detect.

Except for some hack that are specific to one or the other, which I would rather find better solution to.

We have hdr-metadata which is per frame information. Of course we could add a "name" there, but what if the file has multiple HDR metadata baked in? Also I'm in favor of displaying the data as it is used.

danbezerra commented 8 months ago

I would also take advantage of a DV property on my scenario:

  1. All HDR content is tone mapped to SDR BT.2020 (projector user here)
  2. I want to avoid DV metadata when handling P7 MKV rips (potential issue with FEL brightness) so I use vf=format:dolbyvision=no as part of my HDR profile and rely on hdr-compute-peak.
  3. However , for DV Profile 5 I have to re-enable DV support. All other HDR settings from my HDR profile would still apply.

Today, as others have said, DV P5 will fallback to my SDR bt.709 profile, which is wrong and messes up with my Blu-ray profile. I think there could be two ways to properly address this limitation:

a. a new setting that would allow me to turn off dolby vision support only when a 2nd video layer is present (P7). This way I could share my HDR profile with both HDR and DV (P5, P7...) files. b. a new setting that would indicate that a given file is DV P5, allowing me to create a profile specific for this scenario.

Kapppa commented 4 months ago

Any update on this being possibly implemented?

dyphire commented 4 months ago

Any update on this being possibly implemented?

The following auto-profile can be used for DoVi P5.

[DoVi-P5]
profile-cond=p["video-out-params/max-luma"] > 203 and p["video-params/gamma"] == "bt.1886"
profile-restore=copy
...

Other non P5 DoVi videos can only be treated as HDR for processing.

kasper93 commented 3 months ago

profile-cond=p["video-out-params/max-luma"] > 203 and p["video-params/gamma"] == "bt.1886"

After merge of https://github.com/mpv-player/mpv/pull/13458 this has been fixed and will no longer use dummy values in video-*-params

Now you should do something like below for P5. Alternatively you can use video-out-params if you want it to be affected by --vf=format:dolbyvision=no. Depends on use case.

[DoVi-P5]
profile-cond=get("video-params/colormatrix") == "dolbyvision" and get("video-params/colorlevels") == "full"
profile-restore=copy
...
kasper93 commented 1 month ago

track-list/N/dolby-vision-profile and track-list/N/dolby-vision-level has been added, is this enough for you. Or you want something else?