Log in

View Full Version : Getting HDR Info from the C++ API


FranceBB
5th December 2020, 15:17
Hi,
as you know plenty of our workflows rely on Avisynth for pretty much everything.
To get something meaningful out of it, I generally rely on the VideoInfo part of Avisynth in the SDK to forward information to the next blocks in the filterchain or to the encoders, muxers etc.
Things like field parity, bits per pixel, color space, audio channels and so on are easily achievable as I can easily call them from the API and forward the information. The problem I'm facing now is that none of our HDR workflows are... ehm... HDR aware. I remember that a while ago ffms2 was updated to forward the relative HDR information like master display, maxcll etc to VapourSynth so that it could be used by other filters and could also be called via the API, so my question is: where are we in terms of Avisynth? I mean, is there a way to get these properties via the current C++ API? I know I could still run MediaInfo and FFProbe myself on the file before indexing it in Avisynth to get the relative properties and then forward them myself to the relative filters as I make the script (like on HDRTools etc) but that would add yet another step in the chain. Ideally, I would like to be able to get the properties from Avisynth and use them. I know that the .avi stream does not carry any of these things, which is the biggest limitation right now, but isn't it possible to get them by calling the API? I can't find anything in the SDK.

feisty2
5th December 2020, 16:25
these tags are stored as frame properties in vaporsynth, you access them by inspecting properties attached to the first frame of a node.

auto MasteringDisplayWhitePointX = 0.;
auto MasteringDisplayPrimariesX = std::vector<double>{};

if (auto Frame0 = VideoClip[0]; Frame0["MasteringDisplayWhitePointX"].Exists() == false || Frame0["MasteringDisplayPrimariesX"].Exists() == false)
Core.Alert("HDR properties not found!");
else {
MasteringDisplayWhitePointX = Frame0["MasteringDisplayWhitePointX"];
for (auto x : Frame0["MasteringDisplayPrimariesX"])
MasteringDisplayPrimariesX.push_back(x);
}


avisynth+ has supported frame properties last time I checked, so it's theoretically possibly to do this in avisynth+.

FranceBB
11th December 2020, 11:17
Ok, so those are supported in Avisynth as well and not just VapourSynth, right?

feisty2
11th December 2020, 11:38
avisynth+ has provided the facility to do this, but afaic, the ffms2 plugin does not make use of such functionality for avisynth, probably out of compatibility concerns.

FranceBB
11th December 2020, 12:35
avisynth+ has provided the facility to do this, but afaic, the ffms2 plugin does not make use of such functionality for avisynth, probably out of compatibility concerns.

I see... that's unfortunate...

Myrsloik
11th December 2020, 12:40
I see... that's unfortunate...

FFMS2 is quite unfortunate. Create an issue and maybe I'll add support for it.

feisty2
11th December 2020, 12:45
there's nothing stopping you from writing a separate "passthru" filter that does nothing but attaching tags to each frame.