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!
FairPlay Streaming
RSS for tagSecurely deliver streaming media to devices through the HTTP Live Streaming protocol using FairPlay Streaming (FPS).
Posts under FairPlay Streaming tag
41 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hi,
I have a IOS app and we are using fairplay DRM to play videos. In IOS app we are allowing offline download of the videos and hence we are getting a persistent fairplay license. In IOS app everything is working fine.
Now we have used the same app and built for MacOS catalyst. In MAC OS catalyst app we are not able to play the video and getting error code -42650
We are able to get the persistent license from server, but when we play the video with the license we are getting the error. Below are the logs:
2024-12-06 22:05:48.911266+0530 0x4dffe2 Default 0x0 85505 0 teachonline: (MediaToolbox) [com.apple.coremedia:] <<<< FigPKDKeyManager >>>> keyManager_processOfflineKeyInternal: 0x600000322000 160D4519-C60B-4FD0-B69A-20B2A4597017 created decrypt context:0x0 with offline key; updated offline key:0x0 err:-42650
2024-12-06 22:05:48.911369+0530 0x4dffe2 Default 0x0 85505 0 teachonline: (MediaToolbox) [com.apple.coremedia:player] <<<< FigStreamPlayer >>>> fpfs_ensureDecryptorHasStarted: [0x7fc44e4dc520|P/NW] <0x7fc44fa44000|I/SRA.01>: track 1 latching decryptorFailure -42650
85505 0 teachonline: (MediaToolbox) [com.apple.coremedia:player] <<<< FigStreamPlayer >>>> fpfs_StopPlayingItem: [0x7fc44e4dc520|P/NW] <0x7fc44fa44000|I/SRA.01>: Pausing, err=Error Domain=CoreMediaErrorDomain Code=-42650 "(null)"
I have copied only the lines which has errors. You can download the full logs from https://drive.google.com/file/d/1feb9pKZERUr--PMt6m-6IrO_mDvoFbjO/view?usp=sharing
Can you please help me to fix the issue.
Hi,
I have a usecase where I'd like to handle and prevent automatic retries whenever certain errors occur during FairPlay content key requests.
Here's the current flow:
FairPlay certificate is requested and obtained from my server
makeStreamingContentKeyRequestData is called on the keyRequest
The license server will return a 403 along with a body response containing a json with the detailed code and message
The error is caught and handled properly by calling AVContentKeyRequest.processContentKeyResponseError
The AVContentKeySession automatically retries up to 8 times by providing a new key request through public func contentKeySession(_ session: AVContentKeySession, didProvide keyRequest: AVContentKeyRequest)
My license server gets hit with 8 requests that will always result in a 403, these retries are useless
My custom error is succesfully caught later down the line through AVPlayerItem.observe(\.status), this is great
Thing is.. I'd like to catch the 403 error and prevent any retry from being made at step 5, ideally through
public func contentKeySession(_ session: AVContentKeySession, contentKeyRequest keyRequest: AVContentKeyRequest, didFailWithError err: Error)
I've looked for quite a while and just can't seem to find any way of achieving this. Is this not supported at all?
Our iOS/AppleTV video content playback app uses AVPlayer to play HLS video streams and supports both custom and system playback UIs. The Fairplay content key is retrieved using AVContentKeySession. AirPlay is supported too.
When the iPhone is connected to a TV through the lightning Apple Digital AV Adapter (A1438), the app is mirrored as expected.
Problem: when using an iPhone or iPad on iOS 18.1.1, FairPlay-protected HLS streams are not played and a CoreMediaErrorDomain -12035 error is received by the AVPlayerItem. Also, once the issue has occurred, the mirroring freezes (the TV indefinitely displays the app playback screen) although the app works fine on the iOS device.
The content key retrieval works as expected (I can see that 2 content key requests are made by the system by the way, probably one for the local playback and one for the adapter, as when AirPlaying) and the error is thrown after providing the AVContentKeyResponse.
Unfortunately, and as far as I know, there is not documentation on CoreMediaErrorDomain errors so I don't know what -12035 means.
The issue does not occur:
on an iPhone on iOS 17.7 (even with FairPlay-protected HLS streams)
when playing DRM-free video content (whatever the iOS version)
when using the USB-C AV Adapter (whatever the iOS version)
Also worth noting: the issue does not occur with other video playback apps such as Apple TV or Netflix although I don't have any details on the kind of streams these apps play and the way the FairPlay content key is retrieved (if any) so I don't know if it is relevant.
HLS live streaming 4k is not displaying any video, but is streaming audio.
Getting the following errors in the console where it shows that it is failing to decode every frame.
Can I get some help as to what these error codes refer to and why it would fail to decode?
08:30:42.675879-0800 videocodecd AppleAVD: AppleAVDDecodeFrameInternal(): avdDec - Frame# 3588, DecodeFrame failed with error: 0x196
08:30:42.675908-0800 videocodecd AppleAVD: AppleAVDDisplayCallback(): Asking fig to drop frame # 3588 with err -12909 - internalStatus: 315
08:30:42.697412-0800 videocodecd AppleAVD: AppleAVDDecodeFrameResponse(): Frame# 3589 DecodeFrame failed with error 0x00000196
08:30:42.697876-0800 videocodecd AppleAVD: AppleAVDDecodeFrameInternal(): failed - error: 406
Hello, I submitted a request for FPS credentials but haven't received any feedback. How long does it usually take for the credentials to be issued?
Hello, we have HLS stream app and we use AVPlayer for HLS stream. We want to implement dynamic resulotion feature as user's selection. For example, if user want to watch only 1080p user has to watch only 1080p but we have tried to implement "preferredMaximumResolution" and "preferredPeakBitRate" parameters and but AVPlayer does not force it which means that setting preferredMaximumResolution= CGSize(width: 1920, height: 1080) player does not only force to play 1080p profile, player drops resulotion to 720p but we do not want 720p stream if user selected 1080p resulotion. Is there any method to force it even if stream stalls? Thank you in advance
Hello,
I submitted a Request for a Deployment Package. However, I have not received any emails yet. Could you please let me know when I can expect a confirmation message?
Thank you.
I have a FairPlay-encrypted HLS stream and played the video in an AVPlayer.And I want to generate scrubbing thumbnails using the AVAssetImageGenerator.
Also, I am able to generate thumbnails for clear streams but get errors for protected content.
*How to generate thumbnails for protected content.
func getImageThumbnail(forTime: CMTime) {
let generator = AVAssetImageGenerator(asset: asset)
generator.appliesPreferredTrackTransform = true
generator.cancelAllCGImageGeneration()
generator.generateCGImagesAsynchronously(forTimes: [NSValue(time: forTime)]) { [weak self] requestedTime, image, actualTime, result, error in
if let error = error {
print("Error generate: \(error.localizedDescription)")
return
}
if let image = image {
DispatchQueue.main.async {
let image = UIImage(cgImage: image).jpegData(compressionQuality: 1.0)
self?.playerImg.image = UIImage(data: image!)
}
}
}
}
The list of certificates on the Apple Developer web console shows the expiry of my Fairplay Streaming certificate as 'Never'.
However, if I download the same certificate and import it into my KeyChain, the certificate details show the listed expiry as 11 OCT 2023.
Which of these is correct? If the expiry in the certificate is correct, how do I renew it safely.
With my App the below lines fails at the process of -streamingContentKeyRequestData-
CODE
guard
let contentIdData = (loadingRequest.request.url?.host ?? "").data(using: .utf8),
let spcData = try? loadingRequest.streamingContentKeyRequestData(
forApp: certificate!, // This certificate is expired
contentIdentifier: contentIdData,
options: nil
)
else {
print("Error: Failed to generate SPC data due to expired certificate.")
loadingRequest.finishLoading(with: NSError(domain: "com.example.error", code: -3, userInfo: nil))
return false
}
Here is crash logs
NSInvalidArgumentException - *** -[AVContentKeyRequest processContentKeyResponse:] AVContentKeySession's keySystem is not same as that of keyResponse
We observed few 16.X.X Devices are not able to download audio media content, and if they trying multiple times. app got crash and above error encountered while crashing.
Please let us know if any issues.
After the update on iOS 18, FairPlay content does not play.
We get an error: CoreMediaErrorDomain Code=-12891.
this error occurs after sending a ckc message. What does this error mean? Everything works fine on iOS < 18.
When I try to run mediafilesegmenter with the following
mediafilesegmenter -iso-fragmented -z frame_index.m3u8 \
-f 720p -i index_720p \
-k key.bin -stream_encrypt -P
-K <url> \
-B seg_720p -t 6 source.mp4
I get the following output
ISO fragmented mode, forcing segments to start with I-Frame
Processing file source.mp4
track 2 of source.mp4 contains more than one valid time mapping
Unable to find any valid tracks to segment.
Segmenting failed (-15650).
What specifically should I be looking for in my MP4 that would be causing this?
The same H265 encrypted Fairplay content can be played in all Apple devices except A1625.
The clear H265 content is played in A1625.
The question is: will this model (A1625) support H265 Fairplay encrypted content?
A ticket was created here:
https://discussions.apple.com/thread/255658006?sortBy=best
We found that when enabled FairPlay to streams that uses AVC video codec and AC-3 + MP4 audio codec, the playback fails on some devices with CoreMedia error 1718449215 after started playback for about a second.
Successful playback devices: iPhone SE
Failed playback devices: iPhone 12 Pro, iPhone 14 Pro
device iPhone 13 Pro max
AVPlayer recieve error
#Version: 1.0
#Software: AppleCoreMedia/1.0.0.21E236 (iPhone; U; CPU OS 17_4_1 like Mac OS X; en_us)
#Date: 2024/06/11 14:06:18.018
CoreMediaErrorDomain error -42716
On system log we see propertyKey:IsLeaseExpired
стандартное 14:38:28.008912+0300 mediaplaybackd <<<< FigCPECryptorPKD >>>> FigPKDCPECryptorSetKeyRequestResponse: 0xcc4160140 612C5D12-F92F-4897-B55D-854F842B41B4 keyResponseOptions:[] keyRequestResponse:0xcc5759d70 err:-42716
стандартное 14:38:28.009052+0300 mediaplaybackd keyboss ckb_transitionRequestToTerminalState: 0xcc5440380 <private> reqFin err <private> (-42716) dokeyCallbacksExist 0
стандартное 14:38:28.009138+0300 mediaplaybackd keyboss ckb_customURLReadCallback: 0xcc5440380 <private> customURLReqID 8 isComplete 1 err 0 error <private> (0) dokeyCallbacksExist 0
стандартное 14:38:28.009169+0300 mediaplaybackd <<<< FigPKDKeyManager >>>> keyManager_copyPropertyForEntryInternal: 0xcc546b280 6143FF61-5E6F-4506-A17D-4DB6B6BA0C5B propertyKey:IsLeaseExpired propertyValue: 0x16e5b17a0
стандартное 14:38:28.009196+0300 mediaplaybackd <<<< FigPKDKeyManager >>>> PKDKeyManagerSetKeyRequestError: keyManager:0xcc546b280 keyID:6143FF61-5E6F-4506-A17D-4DB6B6BA0C5B error:<private> (-19160) err:0
on server leaseDuration always is 0
But we have another device iPhone 15 Pro max, iOS 17.5.1 and he played correctly with the same crypt key from server
Doing some testing around player behaviour when a license expires in Safari on MacOS. I had the following outcomes:
On Safari 17.4.1 on an intel based Mac running Ventura, playback stopped when the license expired.
On Safari 17.4.1 on an M3 running Sonoma, playback stalled briefly, and then continued to play unlimited.
On Safari 16.5.2 on an M2 running Ventura, playback stalled briefly, and then continued to play unlimited.
When playback stalled briefly, was at the time the license expired.
I parsed the license and everything is set correctly for a lease license type:
{
"version" : 1,
"payloadLength" : 1072,
"iv" : "0H9NCXLQeh1ziYpmJXsnwQ==",
"assetId" : "䙁㉌䉃\u0000\u0000\u0000",
"hdcp" : "TYPE_0_REQUIRED",
"contentKeyDuration" : {
"leaseDurationSeconds" : 300,
"rentalDurationSeconds" : 0,
"persistenceAllowed" : false
},
"keyType" : "Lease"
}
I cannot find any information relating to this behaviour.
Per the docs for FPS, a lease license type: If the content key is not renewed, the Apple device stops the playback when the lease expires. Which is what is observed on the intel based macbook.
Hi everyone, I am having a problem on AVPlayer when I try to play some videos.
The video starts for a few seconds, but immediately after I see a black screen and in the console there is the following error:
<__NSArrayM 0x14dbf9f30>(
{
StreamPlaylistError = "-12314";
comment = "have audio audio-aacl-54 in STREAMINF without EXT-X-MEDIA audio group";
date = "2024-05-13 20:46:19 +0000";
domain = CoreMediaErrorDomain;
status = "-12642";
uri = "http://127.0.0.1:8080/master.m3u8";
},
{
"c-conn-type" = 1;
"c-severity" = 2;
comment = "Playlist parse error";
"cs-guid" = "871C1871-D566-4A3A-8465-2C58FDC18A19";
date = "2024-05-13 20:46:19 +0000";
domain = CoreMediaErrorDomain;
status = "-12642";
uri = "http://127.0.0.1:8080/master.m3u8";
}
)
Is there any update for iOS17 in FairPlay? So far I have found no relevant information.
iOS 16 is fine
Hi,
I am using avplayer, want to stream airplay with my encrypted hls m3u8 url. I am sharing my code snippet.
` let contentUrl = URL(string: String(format:videoUrl))
let headers = ["token": token]
let asset: AVURLAsset = AVURLAsset(url: contentUrl!, options["AVURLAssetHTTPHeaderFieldsKey": headers])
let playerItem: AVPlayerItem = AVPlayerItem(asset: asset)
self.avPlayer?.replaceCurrentItem(with: playerItem)
self.avPlayer?.play()`
Airplay is not working on my tv when i start stream. My encrypted url won't work.
Is there any way to stream airplay with encrypted url. Stuck here........