HLS CMAF/fMP4 CENC CBCS pattern encryption

Hello,

I'm writing a program to create CMAF compliant HLS files, with encryption.

I have a copy of ISO_IEC_23001-7_2023 to attempt to follow the spec.

I am following the 1:9 pattern encryption using CBCS, so for every 16 bytes of encrypted NAL unit data (of type 1 and 5), there's 144 bytes of clear data.

When testing my output in Safari with 'identity' keys Quickly Diagnosing Content Key and IV Issues, Safari will request the identity key from my test server and first few bytes of the CMAF renditions, but will not play and console gives away no clues to the error.

I am setting the subsample bytesofclear/protected data in the senc boxes. What I'm not sure of, is whether HLS/Safari/iOS acknowledges the senc/saiz/saio boxes of the MP4. There are other third party packagers Bento4, who suggest that they do not:

those clients ignore the explicit encryption layout metadata found in saio/saiz boxes, and instead rely purely on the video slice header size to determine the portions of the sample that is encrypted

So now I'm fairly sure I need to decipher the video slice header size, and apply the protected blocks from that point on.

My question is, is that all there is to it? And is there a better way to debug my output? mediastreamvalidator will only work against unencrypted variants (which I'm outputting okay).

Thanks in advance!

HLS CMAF/fMP4 CENC CBCS pattern encryption
 
 
Q