quietvoid / hdr10plus_tool

CLI utility to work with HDR10+ in HEVC files.
MIT License
297 stars 33 forks source link

Trimming video needs recalculating all scenes' first frame and/or frame duration #35

Closed bokeron2020 closed 3 years ago

bokeron2020 commented 3 years ago

Hi, this tool is incredibly useful, so thanks for making it public.

I've been testing a few things, such as scaling down 4K to FHD while keepeing HDR10 and HDR10+ and I've found an otherwise expected behaviour regarding HDR10+ :

If I cut n frames from the beggining of the video using ffmpeg -ss then the metadata is shifted n frames once I remux video stream and HDR10+ extracted with this tool. Obviously expected.

I've tried to extract the metadata piping ffmpeg [...] -ss [...] | hdr10plus_parser [...] but the result doesn't seem to correlate with the expected frames and scenes.

The start and duration for those scenes affected directly by the trimming need to be recalculated, and the rest need to be shifted back into their intended place by -n frames.

So one way would be to write myself a Python script to re-parse the json and do the calculations... and I'm afraid I'm not up to the task. The other way would be to recalculate while parsing it, inside your software.

So here's a request to add this as a command line option somehow, if you find it useful enough of course.

quietvoid commented 3 years ago

Scene information is calculated based on the available metadata per frame, so it's completely independent of any external processing. It's also not data that's from the file itself, just calculated from the complete metadata list.

So the parser has no knowledge of what has been trimmed. JSON is easy to work with anyways.

Also, x265 completely ignores the scene info.