axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools

Home Page:http://www.bento4.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MP4Dash - HLS encrypted CBCS errors with Dolby Vision mp4 source

riba101 opened this issue · comments

Hi there,

I'm running into an issue when I create an fairplay encrypted hls stream (CBCS) with mp4dash when I include a Dolby Vision file that was created on AWS MediaConvert. I also create a Dash stream with Widevine and Playready with the same source files and the stream is encrypted (CENC) and packaged correctly.

The error that occurs is
ERROR: failed to process the file (-10)
ERROR: float division by zero

Update: Testing with files generated by the Dolby Encoding Engine also failed to package with CBCS enabled.

In the meantime I found out that the it fails here.

line 711, in OutputHlsCommon
hls_target_duration = math.ceil(max(track.segment_durations))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: max() arg is an empty sequence

And looking in the debug log I found that the file with Dolby Vision has the following data
Track ID = 1
Segment Count = 0
Type = video
Sample Count = 0
Average segment bitrate = 0
Max segment bitrate = 0
Required bandwidth = 0
Average segment duration = 0

And a normal hvc1 file in the same package job shows the following
Track ID = 1
Segment Count = 51
Type = video
Sample Count = 2405
Average segment bitrate = 6161417
Max segment bitrate = 9638320
Required bandwidth = 7129402
Average segment duration = 1.9200000000000015

Found the issue.

I had to add the following code to Source/C++/Core/Ap4CommonEncryption.cpp at line 293 (the AP4_CencCbcsSubSampleEncrypter::AP4_CencCbcsSubSampleEncrypter block)

if (!hvcc)    hvcc = AP4_DYNAMIC_CAST(AP4_HvccAtom, stsd->FindChild("dvhe/hvcC"));
if (!hvcc)    hvcc = AP4_DYNAMIC_CAST(AP4_HvccAtom, stsd->FindChild("dvh1/hvcC"));

I will create a PR for this

Thanks for finding this out!

Merged in PR #902