Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avformat: validate dovi config in muxers #484

Open
wants to merge 1 commit into
base: jellyfin
Choose a base branch
from

Conversation

gnattu
Copy link
Member

@gnattu gnattu commented Oct 21, 2024

FFmpeg tends to copy any available side packets from the input streams into the muxed output without considering their validity. This behavior is problematic for Dolby Vision configuration records, as invalid records might crash the player. I haven't found a better place to perform such validations with the current Dolby Vision handling process, so I had to place the validation code into each muxers.

This PR checks whether the Dolby Vision record is valid, meaning it is spec-compliant, so the player will likely handle it without issues in movenc, mpegtsenc, and matroskaenc. It first verifies if the codec matches the profile, then checks if the base layer (BL) is encoded as required by the compatibility ID. If the compatibility ID is 0, it also checks if the codec tag is explicitly set to the dovi fourcc, as these videos will not have backward compatibility.

The check in mpegtsenc is slightly stripped down as we are only passing HEVC with BL compat in that muxer.

Changes

Issues

Fixes #483

@gnattu gnattu requested a review from a team October 21, 2024 03:09
@nyanmisaka
Copy link
Member

Is it really necessary to check color_range? Many Profile 5 videos are not correctly labeled. Doing so will prevent them from being recognized by ffprobe -show_streams and change the existing behavior.

@gnattu
Copy link
Member Author

gnattu commented Oct 21, 2024

The intention for this is to not creating tv range profile 5 videos and the muxer will not affect ffprobe. The only problem is that this would prevent those buggy profile 5 videos being remuxed. Maybe we need to remove this check for Profile 5 videos as DoVi players tends to ignore what the container says.

@nyanmisaka
Copy link
Member

The intention for this is to not creating tv range profile 5 videos and the muxer will not affect ffprobe. The only problem is that this would prevent those buggy profile 5 videos being remuxed. Maybe we need to remove this check for Profile 5 videos as DoVi players tends to ignore what the container says.

That's my concern. I haven't tested it yet, but the existing Profile 5 videos that are incorrectly tagged as TV range may not be streamed correctly over fMP4.

@nyanmisaka
Copy link
Member

I suggest putting these validations in the public area like libavformat/dovi_isom.{c,h} to reuse them in multiple muxers. Then we can merge these two patches into one debian/patches/0031-pass-dovi-sidedata-to-muxers.patch.

my draft dovi-validation.patch

@gnattu
Copy link
Member Author

gnattu commented Oct 21, 2024

movenc is slightly different as the code tag is in its own track instead of the par, so the interface needs to be modified slightly.

@nyanmisaka
Copy link
Member

movenc is slightly different as the code tag is in its own track instead of the par, so the interface needs to be modified slightly.

+int ff_isom_validate_dovi_config(const AVDOVIDecoderConfigurationRecord *dovi,
+                                 AVCodecParameters *codec_par, int codec_tag);

I saw that. We can use a separate parameter to handle codec_tag. The upstream will have to deal with this one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tonemap_cuda and tonemap_opencl do not strip DOVI sidedata when targeting SDR
3 participants