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
Passthru Dolby Vision dynamic metadata #4838
Conversation
|
Thank you so much for your effort to implement this. I've tested this on two samples. The first one was a file recorded on my iPhone 12, which DOVI 8.7: |
|
x265 supports only profile 5 and 8. |
Good to know, as "No Time to Die" was going to be the first thing I tried. |
Ah, thanks for your explanation. Didn't know it only works for profiles that x265 supports. On the other hand, the doc says x265 supports 8.1, 8.2 and 8.4, but it was working for me with 8.7 from the iPhone. |
|
x265 values are [Dolby Vision bitstream profile ID].[BL signal cross- compatibility ID], the one reported by mediainfo are in the [Dolby Vision bitstream profile ID].[Dolby Vision Level ID] format. |
|
The latest commits integrate libdovi, so it will convert profile 7 to 8.1 and set the area offsets, and it allow scaling, cropping, and padding. |
ccedf6a
to
202b920
Compare
|
Wow, you are incredible. This works perfectly. It converted the sample from the movie 'No Time to Die' from above nicely from DOVI 7 to DOVI 8. Even with cropping. And it also preserved the HDR10 informations as well. |
|
One issue I found is when scaling down and padding, the level 5 metadata is only set for the specified padding. For example, scaling 2160p to 1080p and padding top/bottom by 76. |
|
Aren't those left/right bar added by the player? If they are not in the actual video I think the value should be zero. I noticed that if I pad the padded area is still tone mapped in QuickTime Player, but it could be that the pad filter is not setting the color to pure black, I'll have to investigate. |
|
Linker trouble on Ubuntu MinGW
|
Oh, you're right the video doesn't have them. edit: nvm the new comment, it really is my player adding the bars because the display has higher resolution. |
|
That's the dimensions tab doing some weird things and making your video anamorphic. There isn't an actual border on left and right, it's just that the pixels are not square because it tries to put the borders in, but the resolution limit is 1080p, so it does change the pixel aspect ratio and squeeze everything to get space for borders. Disable anamorphic, and the resolution limit, to create something more common. |
|
Building as universal binary is now fixed for me on macOS. |
Would you mind making that universal binary available for download? Would love to test on DV iPhone video but am not expert enough to compile myself. |
|
...
Will this work with Video Toolbox as encoder? |
|
Not yet, only x265 for now. I tried some iPhone DV videos but QuickTime Player seem to ignore the the DV part in the converted video. Maybe it requires the Ambient Viewing Environment SEI to work? |
|
FFmpeg quite recently added a number of patches for Ambient Viewing Environment. Would this help us? |
|
FYI, |
|
@sr55 mingw should work now, probably you need to install the windows target with: rustup target add x86_64-pc-windows-gnu |
Sorry, I was busy and have forgotten about this one. Sure, I could, but you can also click on the top on "Actions" and download a build from the "Passthru Dolby Vision dynamic metadata" workflow there. For example this one: https://github.com/HandBrake/HandBrake/actions/runs/4075056980 EDIT: Please ignore the comment above. I have forgotten that you need to explicitly set a flag. I can provide you a UB build on the weekend... |
|
Hi, I ran a test using this and because No Time To Die was mentioned as working I tried that. Dropped all audio and subtitles, selected ultrafast and just told him to send it. I don't know if it disagrees with the encoder speed or what the issue is, but it still dropped the dovi for me. I pastebined the Handbrake log and the mediainfo blurb (for the video portion) for the rip and the encoded file. Maybe I'm doing something wrong or is Windows just not it atm? |
|
It's not enabled in the automatic builds on GitHub yet. You have to build it yourself. |
Much appreciated! Downloaded this build and tried it on a DV 8.4 home video (iPhone 13 Pro) but it doesn't seem to pass through any DV data (tried all different 265 variations). Maybe Galad87's comment means these improvements are not in this build either? |
[link removed] |
Thanks so much, this build works for an iPhone video, selecting h.265 10-bit as the video encoder. |
… vision dynamic metadata if the encoder is x265 and there is no scale/crop/rotate/pad filter.
|
Would be wonderful if it could also work with encoder Video Toolbox, as it's so much faster. |
|
@quietvoid I am getting errors in two frames at the beginning in dvesverifier: https://gist.github.com/galad87/9a5194ffde78cf89967b2ce7aac4066c even when passing through the RPU with zero changes. Something is going not exactly in the right way in x265 or I am passing something wrong to it, do you know a tool to analyse the HEVC NALs and check what's wrong? |
You can simply dump the RPU with So there isn't much we can do about it. I'm not exactly sure about the RPU position errors but this is something you could check with software like hevcesbrowser or just tracing the NALs with ffmpeg. |
|
The source file validates in dvesverifier, but the encoded file has got one at max two errors in the first 20 frames. The exported RPU are exactly the same, I have no idea of what's tripping dvesverifier. One last doubt I have: HandBrake can generate black frames to keep audio/video sync in some weird situations, I assume all frames in a Dolby Vision require a RPU, is there a way to generate one for black frames? |
|
Sorry I had misunderstood. I'm not able to reproduce the verifier errors, even after reencoding with HB. As for the black frames, there isn't a way to generate them from the C API. I guess it is something I'd have to look into. The problem is that generated RPUs are usually not 100% compliant as some metadata levels are missing. |
|
Usually the black frames are inserted at the beginning, if the video don' start at 0, it doesn't happen too often. I could make it save a random RPU during a scan or something like that. |
|
Can this functionality also be added to Video Toolbox encoding? Let me know if I should open a separate issue. |
|
Half a year later, only small bits of this are in FFmpeg upstream. Are there any plans to submit the remaining parts? In particular: |
|
I think you submitted the first one, and I submitted the ambient viewing environment ones. They are on the ffmpeg-devel mailing list. |
|
Right, I've just found your updated submission. Thanks for being upstream-friendly! It makes my life as a package maintainer easier. |
|
Compiling HandBrake using a different version of FFmpeg or other libraries is still a bug fest, but I guess you already know 😝 |
This is required to pass through Dolby Vision metadata to x265. Profiles 5 and 8 require the "dvh1" fourCC: https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby-vision-streams-within-the-http-live-streaming-format-v2.0-13-november-2018.pdf#unique_10 https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolbyvisioninmpegdashspecification_v2_0_public_20190107.pdf#unique_13 https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf See also HandBrake/HandBrake#4838 for more details. Fixes: https://trac.ffmpeg.org/ticket/10257
Implements reading and writing the Dolby Vision Configuration Record and the passing of the RPU buffers to x265.
I tested it on some profile 5 samples and the exported mp4 files can be played back properly in QuickTime Player.
Profile 5 seems to require the "dvh1" fourcc.
It adds a function to check whether to enable the dynamic metadata passthru or not, right now it's enabled only if there is no scaling or crop or rotation or pad and if the encoder is x265 10-bit.
x265 requires vbv-bufsize and vbv-maxrate to be set, I added some arbitrary values if they are not set by the user, if someone has got better ideas please tell.
Test on: