4

I'd like to convert a file recorded from an iPhone 12 to a royalty-free version (for upload to Wikimedia, Flickr, etc). So the transfer involves:

Source (iPhone proprietary-encumbered) Destination (royalty-free)
4k 60fps (UHD, not DCI) 4k 60fps
BT.2020 in HLG (WCG) BT.2020 in HLG (WCG)
Frame-level dynamic HDR metadata in Dolby Vision profile 8.4 Frame-level dynamic HDR metadata in HDR10+
HEVC VP9 (open to AV1 as well but that's likely more nascent)
Bitrate is 31 Mb/s Fine with higher bitrate to maintain same SSIM/PSNR
Audio is in AAC Audio to Vorbis/OGG

According to https://codecalamity.com/encoding-uhd-4k-hdr10-videos-with-ffmpeg/ it should be possible to do most of this. Anyone can help me cook up the right command for this?

MyPreciousss
  • 358
  • 3
  • 13
  • Are you asking how to crack DRM? – harrymc Sep 06 '22 at 07:54
  • What did you try with [`ffmpeg`](https://ffmpeg.org/)? Something like `ffmpeg -i someFile.mp4 -c:a libvorbis -c:v libvpx-vp9 -b:v 3.8M outFile.webm` of course with `-b:v 3.8M` changed with the desired bitrate... Use container you like. There are trillion of options. [Here](https://codecalamity.com/encoding-uhd-4k-hdr10-videos-with-ffmpeg/) a page with hdr10 examples (there are choices you need to make and you can't generalize too much). Do not forget the options for the hardware acceleration, when available. – Hastur Sep 06 '22 at 10:00
  • @harrymc, not really. Videos shot by a user on their phone don't necessarily have 'DRM' in the traditional sense (like Netflix or HTML5 EME) – MyPreciousss Sep 06 '22 at 21:47
  • @Hastur, I've tried a bunch in ffmpeg docs, but didn't find luck. 1. Decoding DoVi's metadata is an issue. 2. Encoding HDR10+ (notice the plus)'s frame-level metadata is another issue that the Codecalamity link you shared also doesn't cover – MyPreciousss Sep 06 '22 at 21:49
  • I'd try [Mediacoder](http://mediacoderhq.com/) which is free for nc use. It has a GUI and a Wizard to help with settings. There's even a version for iphone/ipad – 1NN Sep 07 '22 at 20:52
  • @MyPreciousss Following what they state in the section [Extracting and encoding with HDR10+ metadata](https://codecalamity.com/encoding-uhd-4k-hdr10-videos-with-ffmpeg/#extracting-and-encoding-with-hdr10-metadata)... 2) _FFmpeg builds for Windows **now support HDR10+ metadata files by default**_ and the Linux one too, I suppose, else you can compile. And, if I correct understand, 1) _You will have to download a copy of hdr10plus_parser from quietviod’s repo._ to extract metadata into a `metadata.json` file that they use some lines later (Option 1). – Hastur Sep 12 '22 at 15:15
  • 1
    @MyPreciousss Did you try [makemkv](http://makemkv.com)? BTW on GitHub there is [`dovi_tools`](https://github.com/quietvoid/dovi_tool). Give it a look to something like `dovi_tool -m 2 extract-rpu`... – Hastur Sep 13 '22 at 19:45

2 Answers2

1

Although you have already posted and accepted a negative answer in How to convert Dolby Vision HDR to HDR10+? from 2021, there might exist a method for this conversion.

The recommended tool is ACES from DaVinci Resolve 18. This professional suite is free for personal use.

You will find a description of the method to use in the YouTube video Convert iPhone Dolby Vision to HDR10, described as:

Hi, in this video, I’m going to show you how to convert the iPhone 12 and 13 series' rec2020 HLG (dolby vision) to rec2020 pq or HDR10, that is compatible with more devices like Roku or chromecast when uploading to YouTube. I’ll be using ACES in DaVinci Resolve to achieve this.

Also in the end screen, I've included two videos that I made using this method, one being iPhone 12 Dolby Vision, the other was video from my iPhone 11 Pro shot in rec709 SDR.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Thanks I'm going to try this out before accepting it! 1. The video doesn't differentiate between HDR10+ (Plus) over regular HDR10 as the output. But maybe it outputs frame-level metadata seamlessly? 2. The creator ends up doing manual color grading on the video which won't work here as I want a process that allows anyone to batch-convert their years of various iPhone DoVi videos to HDR10+ equivalents using some 'standard' color transform possible (that works in *most* scenarios/usecases without manual tuning) – MyPreciousss Sep 10 '22 at 19:32
  • Ok, so that flow doesn't work for HDR10+ (regular HDR10 is trivial with ffmpeg) – MyPreciousss Sep 12 '22 at 20:26
  • Even though bounty got auto-awarded here, I don't believe this has solved my question. Maybe ACES is where its at and I need to iterate a bit to get to the final workflow. – MyPreciousss Sep 14 '22 at 00:26
1

ffmpeg

A command line as

ffmpeg -i someFile.mp4  -c:a libvorbis -c:v libvpx-vp9 -b:v 3.8M  outFile.webm

will convert to

  • -c:v libvpx-vp9 VP9
  • -c:a libvorbis Audio to Vorbis/OGG
  • -b:v 3.8M ~31 Mb/s, but you can change according to your wishes

not changing the original resolution nor the FPS.

HDR10+

As for HDR metadata in HDR10+, in the same link posted by the OP (in the updated section Extracting and encoding with HDR10+ metadata), there is an explanation of how to extract the metadata and use it, for example, via the dhdr10-info option in x265-params.

  1. Download download a copy of hdr10plus_parser from quietviod’s repo.

  2. Check your video has HDR10+ info that it can read

    ffmpeg -loglevel panic -i input.mkv -c:v copy -vbsf hevc_mp4toannexb -f hevc - | hdr10plus_parser --verify -
    
  3. Extract and save in the file metadata.json

    ffmpeg -i input.mkv -c:v copy -vbsf hevc_mp4toannexb -f hevc - | hdr10plus_parser -o metadata.json -
    
  4. Use in your expression...

    ffmpeg.exe -i input.mkv -c:v libx265 -pix_fmt yuv420p10le -x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1):max-cll=1016,115:hdr10=1:dhdr10-info=metadata.json" -crf 20 -preset medium "output.mkv"
    
Hastur
  • 18,764
  • 9
  • 52
  • 95
  • I think there is a miscommunication about my question. The source video has DoVi metadata (not HDR10+ metadata). And I want to extract/convert DoVi->HDR10+ metadata for the file. Thanks for helping out though! – MyPreciousss Sep 12 '22 at 20:28
  • 1
    Yep there was. BTW yours is not a single question... We should stick to a single-question single-answer to avoid (minimize) misunderstandings... BTW Did you try [`dovi_tools`](https://github.com/quietvoid/dovi_tool). Give it a look to something like `dovi_tool -m 2 extract-rpu`... – Hastur Sep 13 '22 at 19:50
  • Yeah, have checked out `dovi_tools` before. Here's an issue on that github tracking: https://github.com/quietvoid/dovi_tool/issues/23 – MyPreciousss Sep 14 '22 at 00:24