gpac / gpac

GPAC Ultramedia OSS for Video Streaming & Next-Gen Multimedia Transcoding, Packaging & Delivery
https://gpac.io
GNU Lesser General Public License v2.1
2.78k stars 532 forks source link

Dolby Vision muxing support? #1991

Closed jessielw closed 1 year ago

jessielw commented 2 years ago

Is there a way to actually mux dolby vision encoded files with mp4box? I have been trying for hours, I keep coming across threads with alternative ways but none with mp4box. I have no issues muxing to .ts or .mkv and retaining the proper information. However, once I mux it with mp4box it does not retain the proper information.

If I add the code dv-profile=8.1/5 I get "Dolby Vision, Version 0 / SMPTE ST 2086, HDR10 compatible" when it should say something like "Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible"

Am I doing something wrong or does mp4box not actually support this?

rbouqueau commented 2 years ago

Thanks for reporting.

dv-profile is parsed as an integer. 8.1/5 is not an integer. Maybe an integer is not sufficient or ideal to express these value - please advise about what would be best :)

I get

With which tool do you get these outputs?

jessielw commented 2 years ago

I mean that I have tried 5 and 8.1

Media info cli and GUI both show the same thing when mp4box muxes a dolby vision encode

Also where does the switch dv-profile go in the command line? The documentation wasn't very clear on that.

No matter where ever I put it I always got the same outcome.

rbouqueau commented 2 years ago

Would it be possible to share a sample file?

where does the switch dv-profile go in the command line? The documentation wasn't very clear on that.

I agree. I've created #1993 to improve that.

Current status:

$ MP4Box -h dv-profile
:dv-profile (int):             S set the Dolby Vision profile
jessielw commented 2 years ago

Give me a few minutes and I'll send you a sample of the file

mkv and required no extra switches or effort when muxing from the the original HEVC file to properly display it: https://www.mediafire.com/file/e7bxl8hb8bf368z/Waves.2019.UHD.BluRay.DVTEST.mkv/file

mp4 file (doesn't show/retain proper information): https://www.mediafire.com/file/ze9dzl9dyync32a/Waves.2019.UHD.BluRay.DVTEST.mp4/file

Here is the snippet of the hevc file (encoded with the RPU from source file): https://www.mediafire.com/file/omasvjfflsr2qul/Waves.2019.UHD.BluRay.DVTEST.hevc/file

gacopl commented 2 years ago

@rbouqueau I have same issue though i am encoding properly the file is playable only the codec string is gibberish Dolby Vision Version 0 instead of proper dvhe05.06 codec string like you get when using official dolby tools https://github.com/DolbyLaboratories/dlb_mp4base

FYI @jlw4049 this will make your file playable MP4Box -add video.hevc:dv-profile=5 -add audio.ec3:lang=eng -brand mp42isom -ab dby1 output.mp4 From what i can tell the switch supports only single layer

here is spec https://www.diversifiedvideosolutions.com/Dolby_Vision/Dolby_Vision_profiles_and_levels-Dolby_Laboratories.pdf Section 2.3

rbouqueau commented 2 years ago

I had not seen @jlw4049 's files because he edited the message. I'll have a look soon.

jessielw commented 2 years ago

I had not seen @jlw4049 's files because he edited the message. I'll have a look soon.

Really appreciate it. Encodes with DV will become a normal thing now. Nice to be able to use an mp4 container for it

jeanlf commented 2 years ago

Latest master:

Could you give it a try ?

gacopl commented 2 years ago

Wow that was fast thanks @jeanlf So i compiled static mp4box was a breeze to do And i tested for one workflow so far DV profile 7 dl demuxed with ffmpeg, EL layer discarded with dovi_tools and used mp4box to mix it all together with dv-profile 8. It played well on LG OLED and has correct codec string now so thank you. I can't test more cause it's holiday here and wife screaming :D

Now i just wonder how you handle compatibility layer bit in Dolby muxer it can be set to 1 or 2 defining if it's backward compatible with SDR or HDR. Does your code guess it from NALs ?

jeanlf commented 2 years ago

Now i just wonder how you handle compatibility layer bit in Dolby muxer it can be set to 1 or 2 defining if it's backward compatible with SDR or HDR. Does your code guess it from NALs ?

No this must be set by user:

MP4Box -add src.hevc:dv-profile=8.hdr10 ...
MP4Box -add src.hevc:dv-profile=8.bt709 ...

or during import

gpac -i src.hevc --dv_profile=8 --dv_compatid=hdr10 ...
gpac -i src.hevc --dv_profile=8 --dv_compatid=bt709 ...

I will add warnings if DV compatibility id is not set for profile 8 (my understanding of the spec is that it's OK to use 0 for other profiles).

gacopl commented 2 years ago

Yes sorry shouldhave read the new help :) Very good work much obliged will let you know once i test other scenarios

czw., 6 sty 2022 o 15:47 Jean Le Feuvre @.***> napisał(a):

Now i just wonder how you handle compatibility layer bit in Dolby muxer it can be set to 1 or 2 defining if it's backward compatible with SDR or HDR. Does your code guess it from NALs ?

No this must be set by user:

MP4Box -add src.hevc:dv-profile=8.hdr10 ... MP4Box -add src.hevc:dv-profile=8.bt709 ...

or during import

gpac -i src.hevc --dv_profile=8 --dv_compatid=hdr10 ... gpac -i src.hevc --dv_profile=8 --dv_compatid=bt709 ...

I will add warnings if DV compatibility id is not set for profile 8 (my understanding of the spec is that it's OK to use 0 for other profiles).

— Reply to this email directly, view it on GitHub https://github.com/gpac/gpac/issues/1991#issuecomment-1006648504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMKIAFXWEIZ536SZ4U2RDUUWTR7ANCNFSM5KCD346Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

jeanlf commented 2 years ago

thanks :)

BTW, would you have a sample file for profile 7 (base+el) ?

gacopl commented 2 years ago

I have mkv which is regular UHD rip from which im doin conversion to p8 mp4. I guess i could cut out 2 mins of that mkv for you if you want

czw., 6 sty 2022 o 16:29 Jean Le Feuvre @.***> napisał(a):

thanks :)

BTW, would you have a sample file for profile 7 (base+el) ?

— Reply to this email directly, view it on GitHub https://github.com/gpac/gpac/issues/1991#issuecomment-1006680944, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMKIGKMGOBFR2TUUHUVTTUUWYNVANCNFSM5KCD346Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

jeanlf commented 2 years ago

30s max would be more than enough, I just need to test EL removal

gacopl commented 2 years ago

ok here it is 90 s with meaningful scene to test https://drive.google.com/file/d/1hbUNMbev44o7nSdBrZXhL4wFjo3ZNkqF/view?usp=sharing i tried to use mp4box with direct ffmpeg hevc dump but it didnt work (meaning EL layer was left and no changes to RPU made, it played on LG but scenes were darker clearly missing proper metadata), i have good results only when pass through that hevc dump through dovi_tools to convert RPU to profile 8 and remove EL, then when i mux that BL-RPU extract using mp4box -dv-profile=8 it works as it should

jessielw commented 2 years ago

Using the switch mp4box.exe -add file.hevc:dv-profile-8.hdr10 results in it working pretty much right. However mediainfo picks up the results as follows.

HDR format : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible / SMPTE ST 2086, HDR10 compatible

Notice it says SMPTE ST 2086, HDR10 compatible 2 times, is this an error?

Using the switch mp4box.exe -add file.hevc:dv-profile-8.bt709 results in HDR format : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, SDR compatible / SMPTE ST 2086, HDR10 compatible / SMPTE ST 2086, HDR10 compatible

It says it's SDR compatible, however it also says it's HDR10 compatible

Muxing the file with mkvtoolnix results in this code here HDR format : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible

gacopl commented 2 years ago

Let me rephrase Extracting hevc stream same way for both ffmpeg -t 600 -i input.mkv -c:v copy -vbsf hevc_mp4toannexb -f hevc video.hevc Now This workflow MP4Box -add video.hevc:dv-profile=8.hdr10 -brand mp42isom -ab dby1 output.mp4 Create playing but darkish file While this one creates proper looking and playing dovi_tool -m 2 convert --discard video.hevc #that creates BL_RPU converting from 7 to 8.1 and dumping EL layer MP4Box -add BL_RPU.hevc:dv-profile=8.hdr10 -brand mp42isom -ab dby1 output.mp4

This is regarding LG OLED CX, cause i just found that new MP4Box creates files that no longer play on LG OLED C8, this is due to codecid - in old version it was dvhe with gibberish string, in new version it puts dvh1 (according mediainfo). Now dvh1 is proper spec for profile dvhe08.06 (according to dolby docs), but the source file we have is actually dvhe07.06 codecid dvhe | dhev1 according to dolby's papers

So CX is coping with such file from mp4box though seeking is slow, while with old mp4box both CX and C8 was playing fine and seeking was snappy. I'm still looking into this but I am unsure how this should be, mp4muxer from dolby is putting hev1 in codecid makes it working correctly on CX with very sluggish seeking, and is not working on C8 fallsback to HDR10

Regarding the string this is what i get on that file from dolby's mp4muxer HDR format : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible Codec ID : hev1

This from new MP4BOX: HDR format : Dolby Vision, Version 1.0, dvhe.08.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible / SMPTE ST 2086 Codec ID : dvh1

and this from old MP4BOX HDR format : Dolby Vision, Version 0 / SMPTE ST 2086, HDR10 compatible Codec ID : dvhe

and this from MKV HDR format : Dolby Vision, Version 1.0, dvhe.07.06, BL+EL+RPU, Blu-ray compatible / SMPTE ST 2086, HDR10 compatible Codec ID : V_MPEGH/ISO/HEVC

Now i also peekd at official dolby demo looking glass profile 8.1, its dvhe.08.09 BL+RPU it is codecid hev1, it plays well but does not seek at all on CX so probably LG has issues with any other codecs than dvhe or profile 8 in general, now if I convert that demo using oldmp4box it will change codecid to dvhe and it will work on both CX and C8 flawlessly but it might be just it turns on DV but plays HDR without metadata

Not sure if there's something missing in conversion from profile that this convert is behaving this way, but according to forums and dovi_tools 7 to 8 profile conversion should be working. NVIDIA shield plays them all ofc

Anyways back to topic new MP4BOX is creating different codecid and string than official mp4muxer which might not be wrong actually see UPDATE

UPDATE I compared side by side dvhe, dvh1, hev1 in this particular case of conversion from profile 7, there is visually no difference, but there is difference between these and regular HDR, so RPU is processed by LG OLEDS correctly no matter which codecid there is. dvhe works best in terms of seeking and ffw, dvh1 have issues with short ffws and older oleds dont support it new oleds support it somewhat, hev1 made by mp4muxer is worst very long seeking i think that's a bug as hev1 is meant for sdr fourcc base layer according to their docs not the one we have which is hdr based image Here is a doc for streaming from Dolby 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 Also in this doc it says if string is dvhe.08.06 codec is dvhe, if codec is dvh1 string should be dvh1.08.06, also new mp4box presents codec string as if it was double track double layer not single track double layer (which our original file is) like its totally wrong it should not happen at all even double track, single tracks have 1 instance of that compatibility

MY FINAL CONCLUSION ON PROFILE 8 support is here's what MP4Box should do as I've read all dolbys docs AS IT'S NOT PERFORMING TRANSCODING IT SHOULD TAKE CODECID FROM INPUT AND PUT IT THE SAME REGARDLESS OF PROFILE CHOSEN

8.none = codecid=dvhe # this is possible per spec so i should be able to set that and get that, now getting dvh1 which is not right as dvh1 codecs are backward compatible, if i'm choosing none it has to be dvhe - even dovi tools have conversion option between profile 5(dvhe) to 8.0 aka 8.none 8.hdr = codecid=dvh1 | hev1 depending which actual codec is used in input stream

8.sdr and rest = codecid=hev1 # this is on aligning with looking glass demo as its BL is compatible back to SDR and if I understood correctly dvh1 is compatible back only to HDR10 and BT2020

sources: https://www.diversifiedvideosolutions.com/Dolby_Vision/Dolby_Vision_profiles_and_levels-Dolby_Laboratories.pdf 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 https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf

gacopl commented 2 years ago

Actually if you spend time reading this carefully https://www.avsforum.com/threads/authoring-dolby-vision-compatible-compliant-mp4-files-for-htpc-media-server-updated-01-02-2022.3212211/ up to muxing section you will understand why dvhe should be used, also dvh1 needs to be coded properly to be dvh1, havent seen uhd disc that is coded in dvh1 yet only some mp4 and hls streams.

Man my head is burning right now :) for the time being i will stick to older mp4box at least it works for me even if the codec string representation is wrong codecid is correct, i also tried using new mp4box and hexediting codecid and yes then it works. So I would suggest that since you can have so many codecid in profile 8 you can't guess other than looking at input stream or allowing override

Thanks for your work!

jeanlf commented 2 years ago

dhv1 is DV wrapper for hvc1, dvhe is wrapper for hev1, i.e. in-band parameter sets

So you will get a dvhe codec type if you mux using:

MP4Box -add source.hvc:dv-profile=5:xps_inband -new res.mp4

It seems the dolbylabs mp4 muxer only creates in-band config (whether input is AVC or HEVC).

The duplicated HDR10 compatible / SMPTE ST 2086 from mediainfo comes from the presence of HDR meta-data in the sample description for mp4box, which is not added by dolbylabs muxer.

This info can now be removed using latest master:

MP4Box -add source.hvc:dv-profile=5:xps_inband:hdr=none -new res.mp4

Importing with the latest master will keep the hevc/ hev1 codec signaling for profiles other than 1, 3 or 5, but the codec can be changed by specifying 'f' prefix:

MP4Box -add source.hvc:dv-profile=f8.1:xps_inband -new res.mp4

will give dvhe

and

MP4Box -add source.hvc:dv-profile=8.1:xps_inband -new res.mp4

will give hev1

This allows to deal with compliant vs non-compliant base layer in DV, which cannot be detected at parsing time.

gacopl commented 2 years ago

Thanks a lot will try to play around soon with it, also JFYI i noticed mp4muxer always muxes profile 5 with dvhe i'm referring to this MP4Box -add source.hvc:dv-profile=5:xps_inband -new res.mp4 i was not aware you can have hev1 in profile 5 only in profile 7 when having double track situation so i think for profile=5 that xps_inband should not be needed or enabled by default for profile 5

gacopl commented 2 years ago

I tested this with profile 5, 7, 8 single layers and am happy with result, i have an issue with seeking though with source in profile 8 when converted from mkv to mp4 it stops seeks on anything except VLC, i guess i need to learn more about fixing indexing in mp4

jeanlf commented 2 years ago

Latest master should now be able to split and reagg dual-DV streams (cf test, even if test source only has RPU... )

I also added avcE and hvcE as they seem mandatory, and force single track per moov per the spec for dashing.

gacopl commented 2 years ago

These should be added only when it's not DV wrapped codec like hev1

pt., 21 sty 2022, 18:57 użytkownik Jean Le Feuvre @.***> napisał:

Latest master should now be able to split and reagg dual-DV streams (cf test https://github.com/gpac/testsuite/blob/master/scripts/bssplit.sh#L17, even if test source only has RPU... )

I also added avcE and hvcE as they seem mandatory, and force single track per moov per the spec for dashing.

— Reply to this email directly, view it on GitHub https://github.com/gpac/gpac/issues/1991#issuecomment-1018735818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMKIBUZDUQLO5XP37ZLT3UXGNAVANCNFSM5KCD346Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

gacopl commented 2 years ago

Hi @jeanlf I have to reopen this, would there be possiblity to add old dolby vision behaviour with a switch? files created with with mp4box post these changes are not playable on LG C8. Files created with mp4box 1.0.1 play fine even though the codec string is wrong "Dolby Vision, Version 0 / SMPTE ST 2086, HDR10 compatible" Can we get a switch to trigger this hack behaviour? Also i can't make profile 8.0 -8.none does not work

jeanlf commented 2 years ago

use either one of:

MP4Box -add source.hvc:dv-profile=0 -new dst.mp4
MP4Box -add source.hvc --dv_profile=0 -new dst.mp4
gpac -i source.hvc:dv_profile=0 -o dst.mp4

Do you have any clue why the LG C8 reject these files ? Do you have a working sample for this TV ?

gacopl commented 2 years ago

I have tried dv-profile=0 but it not works not playing not engaging dv neither on CX or C8, with 1.0.1 it worked like i was setting dv-profile=8 for instance and i guess it prepared media correctly just the string was different So with new mp4box and dv-profile=0, mediainfo shows not playable

HDR format                               : Dolby Vision, Version 1.0, dvav.00.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible / SMPTE ST 2086
Codec ID                                 : hvc1

with new mp4box and dv-profile=f0:xps_inband shows not playable

HDR format                               : Dolby Vision, Version 1.0, dvav.00.06, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible / SMPTE ST 2086
Codec ID                                 : dvhe

with old 1.0.1 mp4box and dv-profile=8 and it WORKS both on LG CX and C8 mediainfo shows

HDR format                               : Dolby Vision, Version 0 / SMPTE ST 2086, HDR10 compatible
Codec ID                                 : dvhe
Codec ID/Info                            : High Efficiency Video Coding with Dolby Vision

The reason i am asking this is just i don't want to be pegged to 1.0.1 forever

jeanlf commented 2 years ago

Could you try muxing with e.g.

MP4Box -add source:dv-profile=f8.hdr10 --xps_inband=both -new test.mp4

You can also set :hdr=none option to remove mdcv and clli boxes

gacopl commented 2 years ago

No luck with both still not playable on C8 i will try to prepare short sample files from same source and exact RPU one that is working and one that is not

gacopl commented 2 years ago

hi @jeanlf Here are samples https://drive.google.com/drive/folders/1BWst_Gsjsr5MUIVGmolCBaEKtSOhRqur?usp=sharing file 1.mp4 has been created with mp4box 1.0.1 WORKS FINE ON LG C8

MP4Box -add BL_RPU.hevc:dv-profile=8 -add "1.eng.eac3":sopt:gfreg=ffdmx -lang 2=eng -brand mp42isom -ab dby1 1.mp4

file2.mp4 has been created with newest MP4Box DOESNT WORK ON LG C8, works somewhat on CX but seeking is lagging

mp4box-new -add BL_RPU.hevc:dv-profile=f8.hdr10:hdr=none --xps_inband=both -add "1.eng.eac3":sopt:gfreg=ffdmx -lang 2=eng -brand mp42isom -ab dby1 "2.mp4"

Therefore for now i make users of my project stick to 1.0.1 https://github.com/gacopl/dvmkv2mp4 we would be happy to get same behaviour with some switch on MP4Box 2.0

zfeher commented 2 years ago

Hi'

First of all thank you for the dolby vision support, it will be really handy, and quicker than demuxing and using dolby mp4muxer.

Testing the MP4Box dolby vision support with GPAC 2.0 (and 2.1 rev74) I noticed a slight difference in HDR format comparing with the original MKV video.

glass blower DV profile 8 MKV

Format: HEVC
HDR Format: Dolby Vision, Version 1.0, dvhe.08.09, BL+RPU, Blu-ray compatible / SMPTE ST 2086, HDR10 compatible
Codec ID: V_MPEGH/ISO/HEVC

glass blower DV profile 8 MP4

Format: HEVC
HDR Format: Dolby Vision, Version 1.0, dvhe.08.0A, BL+RPU, HDR10 compatible / SMPTE ST 2086, HDR10 compatible
Codec ID: dvhe

dvhe.08.0A instead dvhe.08.09. Feels like this is off by one.

made with

mp4box -add p8.glass.blower.mkv:dv-profile="f8.hdr10:xps_inband" -brand mp42isom -ab dby1 -new p8.glass.blower.mp4

The same applies to the dolby amaze DV profile 5 video too: dolby amaze DV profile 5 MKV

Format: HEVC
HDR Format: Dolby Vision, Version 1.0, dvhe.05.09, BL+RPU
Codec ID: V_MPEGH/ISO/HEVC

dolby amaze DV profile 5 MP4

Format: HEVC
HDR Format: Dolby Vision, Version 1.0, dvhe.05.0A, BL+RPU
Codec ID: dvhe

Again it is off by one dvhe.05.0A instead of dvhe.05.09

made with

mp4box -add p5.dolby-amaze.mkv:dv-profile="f5.none:xps_inband" -brand mp42isom -ab dby1 -new p5.dolby-amaze.mp4

Fortunatelly my LG OLED C1 TV can playback both mp4-s just fine, DV is triggered (sadly DV mkv-s are not supported). Maybe this slight diff matters for other TVs, players.

MakeMKV DV sample files

jeanlf commented 2 years ago

@zfeher thanks for the files. The bug was due to mkv's use of 1khz timescales causing rounding issues in FPS being detected as greater than 60 hz, should now be fixed

@gacopl Thanks for the files. There are two main differences I can see:

Could you try muxing using:

MP4Box -add BL_RPU.hevc:dv-profile=f8.hdr10:hdr=none:stype=dvhe -brand mp42isom -ab dby1 -new 2.mp4

If still not working then the issue is coming from the dvcC box itself

mohd-akram commented 2 years ago

For reference, Dolby has some sample media here - https://developer.dolby.com/tools-media/sample-media/video-streams/dolby-vision-streams/. These files work correctly on several devices that I tested with. It's important to use dvh1 and not dvhe (for profile 5), and hvc1 and not hev1 (for profile 8) (unfortunately the profile 8 sample uses the latter which deems it unplayable on Apple devices). When using Dolby's mp4muxer, these are the --dvh1flag and --hvc1flag flags respectively. I've found bento4's mp4info more helpful than mediainfo in seeing the difference between files. Hope this helps.

I've also noticed some files with Dolby Atmos refused to play on my (Sony) TV due to them using codec id ac-3 for "Dolby Digital Plus with Dolby Atmos" instead of the ec-3 codec id.

rbouqueau commented 2 years ago

In case it helps: https://www.elecard.com/page/article_hdr

quietvoid commented 2 years ago

Could you try muxing using:

MP4Box -add BL_RPU.hevc:dv-profile=f8.hdr10:hdr=none:styp=dvhe -brand mp42isom -ab dby1 -new 2.mp4

@jeanlf Is that command line supposed to work? I get this error: Unrecognized import option styp=dvhe, ignoring

That's on MP4Box - GPAC version 2.1-DEV-rev184-g30b4328c0-master

jeanlf commented 2 years ago

sorry, typo - missing e, should be :stype=dvhe

quietvoid commented 2 years ago

Thanks.

I can confirm that by default, dvh1 doesn't work on my LG C8. And using stype=dvhe does not work either.

Working file (made with Dolby's old mp4muxer, 2018 version): https://0x0.st/oaLe.mp4 Not working (GPAC): https://0x0.st/oaL2.mp4

Dolby's current mp4muxer does not work either, at least for my C8.

The only thing I notice is that Dolby didn't add the compatibility ID before, but it's necessary for profile 8 in GPAC. Hopefully the samples help.

gacopl commented 2 years ago

quietvoid mp4box 1.0.1 produces filr that works on c8, this is to make mp4box2 work same way.

Checkout dvmkv2mp4

sob., 21 maj 2022, 15:15 użytkownik quietvoid @.***> napisał:

Thanks.

I can confirm that by default, dvh1 doesn't work on my LG C8. And using stype=dvhe does not work either.

Working file (made with Dolby's old mp4muxer, 2018 version): https://0x0.st/oaLe.mp4 Not working (GPAC): https://0x0.st/oaL2.mp4

The only thing I notice is that Dolby didn't add the compatibility ID before, but it's necessary for profile 8 in GPAC. Hopefully the samples help.

— Reply to this email directly, view it on GitHub https://github.com/gpac/gpac/issues/1991#issuecomment-1133632478, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMKIBBIP6JZLQSOUJ2HKDVLDOWHANCNFSM5KCD346Q . You are receiving this because you were mentioned.Message ID: @.***>

quietvoid commented 2 years ago

I'm aware, the goal should still be to have working files using 2.0. As mentioned before, 1.0.1 outputs an invalid Dolby Vision configuration record.

quietvoid commented 2 years ago

Just FYI, files made by 2.0 work fine on my new LG C2.

nilaoda commented 2 years ago

@jeanlf Hi, when i remux DoVi profile 8.4 content (from UGC), latest mp4box give me warning [iso file] dvcC profile 8 but compatibility ID 4 is not 1 or 2, patching to 2.


Original file:

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5.1@Main
HDR format                               : Dolby Vision, Version 1.0, dvhe.08.08, BL+RPU, HLG compatible
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 6 min 30 s
Bit rate                                 : 3 596 kb/s
Width                                    : 3 840 pixels
Height                                   : 1 728 pixels
Display aspect ratio                     : 2.222
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0 (Type 0)
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.009
Stream size                              : 167 MiB (100%)
Writing library                          : x265 0.0:[Linux][GCC 6.3.0][64 bit] 10bit
Encoding settings                        : cpuid=1111039 / frame-threads=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x1728 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=3 / no-allow-non-conformance / repeat-headers / annexb / aud / hrd / info / hash=1 / no-temporal-layers / no-open-gop / min-keyint=300 / keyint=300 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=8 / scenecut=0 / hist-scenecut=0 / radl=0 / splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=1 / no-limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=3 / selective-sao=4 / early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=0.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=21.0 / qcomp=0.60 / qpstep=4 / stats-write=1 / stats-read=0 / slow-firstpass / vbv-maxrate=12000 / vbv-bufsize=12000 / vbv-init=0.8 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=18 / colormatrix=9 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / hist-threshold=0.01 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / no-scenecut-aware-qpconformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0
Default                                  : Yes
Alternate group                          : 1
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant
Codec configuration box                  : hvcC+dvvC

My command:

mp4box -add input.mp4 -new output.mp4

The output:

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5.1@Main
HDR format                               : Dolby Vision, Version 1.0, dvhe.08.08, BL+RPU, SDR compatible
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 6 min 30 s
Bit rate                                 : 3 596 kb/s
Maximum bit rate                         : 12.8 Mb/s
Width                                    : 3 840 pixels
Height                                   : 1 728 pixels
Display aspect ratio                     : 2.222
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0 (Type 0)
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.009
Stream size                              : 167 MiB (100%)
Writing library                          : x265 0.0:[Linux][GCC 6.3.0][64 bit] 10bit
Encoding settings                        : cpuid=1111039 / frame-threads=16 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x1728 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=3 / no-allow-non-conformance / repeat-headers / annexb / aud / hrd / info / hash=1 / no-temporal-layers / no-open-gop / min-keyint=300 / keyint=300 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=20 / lookahead-slices=8 / scenecut=0 / hist-scenecut=0 / radl=0 / splice / no-intra-refresh / ctu=64 / min-cu-size=8 / no-rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=0 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=1 / no-limit-modes / me=1 / subme=2 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=3 / selective-sao=4 / early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=0.00 / psy-rdoq=0.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=21.0 / qcomp=0.60 / qpstep=4 / stats-write=1 / stats-read=0 / slow-firstpass / vbv-maxrate=12000 / vbv-bufsize=12000 / vbv-init=0.8 / crf-max=0.0 / crf-min=0.0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=1 / overscan=0 / videoformat=5 / range=0 / colorprim=9 / transfer=18 / colormatrix=9 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=1023 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / hist-threshold=0.01 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / no-scenecut-aware-qpconformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0
Default                                  : Yes
Alternate group                          : 1
Tagged date                              : UTC 2022-08-31 13:21:36
Color range                              : Limited
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant
Codec configuration box                  : hvcC+dvvC

I wonder that why you add this warning and force to set compatibility to 2? https://github.com/gpac/gpac/commit/291435b2781f35ba3f82663173d26ac8ca37263c

sw5163 commented 2 years ago

May I ask if there is an option to convert dvhe->dvh1 when import mp4? For example something like: mp4box -add dvhe.mp4:dvh1flag=true -new dvh1.mp4 I can't use stype=dvh1 because it doesn't change 'sample box entry' and will cause black screen on iOS/ATV playback.

I couldn't find related option in wiki and sorry for me being stupid if there is any.

Currently I'm using: ffmpeg -i dvhe.mp4 -c copy dv.hevc mp4box -add dv.hevc -new dvh1.mp4 But it would be nice if I could just skip the ffmpeg step. Thanks.

jessielw commented 2 years ago

I was curious if there was a definitive option we should use when muxing DV with mp4box now?

I see there have been many changes it seems throughout the versions.

MP4Box -add src.hevc:dv-profile=8.hdr10 ... MP4Box -add src.hevc:dv-profile=8.bt709 ...

Is this still the best way?

Additionally is there any chance of automatic detection in the future similar to how mkvmerge/mkvtoolnix does it?

jeanlf commented 2 years ago

@nilaoda indeed the patching of the CCID is incorrect, now fixed.

jeanlf commented 2 years ago

@sw5163 yes there is:

MP4Box -add source_dvhe.mp4:dopt:xps_inband=no -new source_dvh1.mp4

the :dopt: option indicates thet full remux of the track is needed, and xps_inband=no is the option of the muxer you want to not use inband parameter sets

nilaoda commented 2 years ago

@nilaoda indeed the patching of the CCID is incorrect, now fixed.

Thanks! Now it's working properly.

sw5163 commented 2 years ago

MP4Box -add source_dvhe.mp4:dopt:xps_inband=no -new source_dvh1.mp4

Thank you so much, works like a charm!

jeanlf commented 2 years ago

@jlw4049 and all

latest master:

Could you test if this works better on your various devices ?

mohd-akram commented 2 years ago

@jeanlf This is really great, thank you!

I just tried muxing a file with the following:

MP4Box -new -brand mp42 -ab dby1 -add "video.hevc" -add "audio.eac3" "out.mp4"

I can confirm that it generates a file with the correct Dolby Vision parameters (in this case it was 8.1), and also preserves Dolby Atmos information. The file works in QuickTime on my Mac as well as on my Sony TV.

sw5163 commented 2 years ago

I can confirm that it generates a file with the correct Dolby Vision parameters (in this case it was 8.1), and also preserves Dolby Atmos information. The file works in QuickTime on my Mac as well as on my Sony TV.

Are you certain P8.1 file plays Dolby Vision in QuickTime on Mac? On my iPad Pro 2017 (iOS 15.4) only file tagged with P5 dvh1 plays proper Dolby Vision through native player. @quietvoid's test pattern P8.1 hvc1 plays as standard HDR10 P8.1 dvh1 contrast is wrong

mohd-akram commented 2 years ago

The file plays although I can't tell if it's playing as HDR10 or DV, probably the former since I don't see any changes in the video (and per their website my Mac is not supported). Tried it on my TV though and I see it change. Apple's DV support is all over the place right now, different devices support different profiles.