Streaming

RSS for tag

Deep dive into the technical specifications that influence seamless playback for streaming services, including bitrates, codecs, and caching mechanisms.

Streaming Documentation

Posts under Streaming subtopic

Post

Replies

Boosts

Views

Activity

Playing clear-key DRM protected video with AVFoundation
I’m wondering if there is any way to play a clear-key DRM-protected video stream. I have {"clear-key-id": "clear-key"} pair, but I don’t know how to do it in code. It is not FairPlay Streaming nor Widevine. I override resourceLoader(_:shouldWaitForLoadingOfRequestedResource:) and done something similar to this: let key = "{\"key\": \"452948404d635166546a576e5a723475\",\"keyId\": \"2f423f4528482b4d6251655468576d5a\"}" let keyData = Data(key.utf8) loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryPersistentContentKeyType loadingRequest.contentInformationRequest?.isByteRangeAccessSupported = true loadingRequest.contentInformationRequest?.contentLength = Int64(keyData.count) loadingRequest.dataRequest?.respond(with: keyData) loadingRequest.finishLoading() I do not think this is the correct way to do it, as I arbitrarily loaded the key as a raw string and compressed it to Data type. I think there should be some API or func to call for that clear-key-based DRM.
0
0
1.5k
Feb ’23
Does FairPlay work for iPad on iOS 15.4 ?
Website serving Apple FairPlay videos here... I have three users reporting problems with playback using Safari on iPad with iOS 15.4. It seems they can no longer use Chrome (where we serve the same videos using DASH+CENC) either. That is all I know at this time. Not finding anything from google except the 15.1 FairPlay debacle... Just fishing. Anything similar for anyone else? Thank you kindly.
1
0
1.1k
Mar ’22
HLS EVENT Manifest Safari Player Timeline crash
We have implemented an optimization feature for HLS VOD streaming in the form of an EVENT Manifest. General manifest hour The bottom line is that on the first request, we return the HLS EVENT Manifest within 30 seconds and launch certain processin mechanisms in the background, as soon as everything has ready, on the next requests we return an EVENT Manifest with an EXT-X-ENDLIST tag What does it look like 1st request: #EXTM3U #EXT-X-PLAYLIST-TYPE: EVENT 1.ts 2.ts 3.ts 2nd req (if background completed) #EXTM3U #EXT-X-PLAYLIST-TYPE: EVENT 1.ts 2.ts 3.ts .... .... .... 1000.ts #EXT-X-ENDLIST This approach worked in VLC player and hls.js players but this thing doesn't work in native Safari player It has very strange behavior: Live is shown first in the timeline (which is okay) then, as he has already downloaded the manifest with EXT-X-ENDLIST, it shows the real duration (hour) but literally after 2 seconds it cuts the timeline and leaves only 2 minutes in the timeline by DevTools-> Network, I see that it stops downloading after 8-9 segments And now I would like to know if anyone has encountered such a safari problem and if maybe you need to somehow reconfigure the browser player.
1
0
1.1k
May ’23
Mediastreamvalidator Error: Invalid URL
I try to validate low latency HLS fragmented MP4 setup with meadistreamvalidator. I get following error: Error: Invalid URL Detail: '(null)' is not a valid URL Source: mediaplaylistURL.m3u8 - segmentURL.mp4 meadistreamvalidator version is 1.23.14 What does that error mean?
1
0
437
Dec ’24
Use AVPlayer for multiple videos
I'm developing a tutorial style tvOS app with multiple videos. The examples I've seen so far deal with only one video. Defining the player and source(url) before body view let avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../video.mp4")!)) and then in the body view the video is displayed VideoPlayer(player: avPlayer) This allows options such as stop/start etc. When I try something similar with a video title passed into this view I can't define the player with this title variable. var vTitle: String var avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../" + vTitle + ".mp4"")!)) var body: some View { I het an error that vTitle can't be used in the url above the body view. Any thoughts or suggestions? Thanks
1
0
1.3k
Dec ’24
SCTE-35 markers events on Safari
Hello,When streaming and playing HLS streams on Safari using <video> tag, is there way to be notified at application level (javascript) of the presence of SCTE-35 data ranges in the stream (playlist)?When using the <video> tag on Safari, it is the responsibility of the the native video element to download and parse the playlists, thus there is no way for web application to know about the presence of such tags/markers in the playlists.Does the native video element trigger some events (like cue events for example) to signal the presence of these SCTE-35 data ranges?I tried to listen for cue events but unsuccessfully.
1
0
1.6k
Jun ’23
HLS black screen on all ios devices
Our custom software takes RTSP from cctv cameras and turns it into an RTSP stream that we play through calppr player. One particular model of camera wont play on ios devices. It is just all black when trying to play it. on ios (all versions of ios) It still works great on PC, Mac, and Android. Our hls stream is video only. There is no audio. The problem is not with the player because I tested other players and they do the same thing on iOS. Black screen or at best they freeze on the first picture and don't ever move. Any advice on what the problem may be? Thank you so much!
1
0
1.9k
Jun ’22
Fairplay error on MacOS catalyst
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.
1
1
967
Dec ’24
iOS 15: AVPlayer stays on lowest quality HLS Stream
Is anyone encountering an issue where their HLS files are no longer working with iOS 15 AVPlayer? We are seeing the player stay on the lowest quality variant (that is the lowest bit rate HLS option) for about a minute before changing to the highest quality, despite being on a great network connection throughout. This is reproducible on an isolated project with nothing but the the AVPLayer loading a m3u8 URL. We have not been able to find anything about AVPlayer that changed or would cause this in iOS 15. Are we missing anything? Also - We have been trying to locate an HLS example for audio that also passes the Apple HLS validator - does anyone know where that can be found? We did not have luck with the examples on Apple's developer site as they are out of date with the validator it seems like. We thought that maybe there's an issue with our HLS streams despite them working before sub iOS 15. But it's tough to find a good example of anything that passes the validator. Any input would be awesome, thank you!
1
0
1.3k
Nov ’21
iOS Radio App: Need to extract and stream audio-only from HLS streams with video content
I'm developing an iOS radio app that plays various HLS streams. The challenge is that some stations broadcast HLS streams containing both audio and video (example: https://svs.itworkscdn.net/smcwatarlive/smcwatar/chunks.m3u8), but I want to: Extract and play only the audio track Support AirPlay for audio-only streaming Minimize data usage by not downloading video content Technical Details: iOS 17+ Swift 5.9 Using AVFoundation for playback Current implementation uses AVPlayer with AVPlayerItem Current Code Structure: class StreamPlayer: ObservableObject { @Published var isPlaying = false private var player: AVPlayer? private var playerItem: AVPlayerItem? func playStream(url: URL) { let asset = AVURLAsset(url: url) playerItem = AVPlayerItem(asset: asset) player = AVPlayer(playerItem: playerItem) player?.play() } Stream Analysis: When analyzing the video stream using FFmpeg: CopyInput #0, hls, from 'https://svs.itworkscdn.net/smcwatarlive/smcwatar/chunks.m3u8': Stream #0:0: Video: h264, yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps Stream #0:1: Audio: aac, 44100 Hz, stereo, fltp Attempted Solutions: Using MobileFFmpeg: let command = [ "-i", streamUrl, "-vn", "-acodec", "aac", "-ac", "2", "-ar", "44100", "-b:a", "128k", "-f", "mpegts", "udp://127.0.0.1:12345" ].joined(separator: " ") ffmpegProcess = MobileFFmpeg.execute(command) Issue: While FFmpeg successfully extracts audio, playback through AVPlayer doesn't work reliably. Tried using HLS output: let command = [ "-i", streamUrl, "-vn", "-acodec", "aac", "-ac", "2", "-ar", "44100", "-b:a", "128k", "-f", "hls", "-hls_time", "2", "-hls_list_size", "3", outputUrl.path ] Issue: Creates temporary files but faces synchronization issues with live streams. Requirements: Real-time audio extraction from HLS stream Maintain live streaming capabilities Full AirPlay support Minimal data usage (avoid downloading video content) Handle network interruptions gracefully Questions: What's the most efficient way to extract only audio from an HLS stream in real-time? Is there a way to tell AVPlayer to ignore video tracks completely? Are there better alternatives to FFmpeg for this specific use case? What's the recommended approach for handling AirPlay with modified streams? Any guidance or alternative approaches would be greatly appreciated. Thank you!
1
1
630
Dec ’24
Decode HLS livestream with VideoToolbox
Hi, I'm trying to decode a HLS livestream with VideoToolbox. The CMSampleBuffer is successfully created (OSStatus == noErr). When I enqueue the CMSampleBuffer to a AVSampleBufferDisplayLayer the view isn't displaying anything and the status of the AVSampleBufferDisplayLayer is 1 (rendering). When I use a VTDecompressionSession to convert the CMSampleBuffer to a CVPixelBuffer the VTDecompressionOutputCallback returns a -8969 (bad data error). What do I need to fix in my code? Do I incorrectly parse the data from the segment for the CMSampleBuffer? let segmentData = try await downloadSegment(from: segment.url) let (sps, pps, idr) = try parseH264FromTSSegment(tsData: segmentData) if self.formatDescription == nil { self.formatDescription = try CMFormatDescription(h264ParameterSets: [sps, pps]) } if let sampleBuffer = try createSampleBuffer(from: idr, segment: segment) { try self.decodeSampleBuffer(sampleBuffer) } func parseH264FromTSSegment(tsData: Data) throws -> (sps: Data, pps: Data, idr: Data) { let tsSize = 188 var pesData = Data() for i in stride(from: 0, to: tsData.count, by: tsSize) { let tsPacket = tsData.subdata(in: i..<min(i + tsSize, tsData.count)) guard let payload = extractPayloadFromTSPacket(tsPacket) else { continue } pesData.append(payload) } let nalUnits = parseNalUnits(from: pesData) var sps: Data? var pps: Data? var idr: Data? for nalUnit in nalUnits { guard let firstByte = nalUnit.first else { continue } let nalType = firstByte & 0x1F switch nalType { case 7: // SPS sps = nalUnit case 8: // PPS pps = nalUnit case 5: // IDR idr = nalUnit default: break } if sps != nil, pps != nil, idr != nil { break } } guard let validSPS = sps, let validPPS = pps, let validIDR = idr else { throw NSError() } return (validSPS, validPPS, validIDR) } func extractPayloadFromTSPacket(_ tsPacket: Data) -> Data? { let syncByte: UInt8 = 0x47 guard tsPacket.count == 188, tsPacket[0] == syncByte else { return nil } let payloadStart = (tsPacket[1] & 0x40) != 0 let adaptationFieldControl = (tsPacket[3] & 0x30) >> 4 var payloadOffset = 4 if adaptationFieldControl == 2 || adaptationFieldControl == 3 { let adaptationFieldLength = Int(tsPacket[4]) payloadOffset += 1 + adaptationFieldLength } guard adaptationFieldControl == 1 || adaptationFieldControl == 3 else { return nil } let payload = tsPacket.subdata(in: payloadOffset..<tsPacket.count) return payloadStart ? payload : nil } func parseNalUnits(from h264Data: Data) -> [Data] { let startCode = Data([0x00, 0x00, 0x00, 0x01]) var nalUnits: [Data] = [] var searchRange = h264Data.startIndex..<h264Data.endIndex while let range = h264Data.range(of: startCode, options: [], in: searchRange) { let nextStart = h264Data.range(of: startCode, options: [], in: range.upperBound..<h264Data.endIndex)?.lowerBound ?? h264Data.endIndex let nalUnit = h264Data.subdata(in: range.upperBound..<nextStart) nalUnits.append(nalUnit) searchRange = nextStart..<h264Data.endIndex } return nalUnits } private func createSampleBuffer(from data: Data, segment: HLSSegment) throws -> CMSampleBuffer? { var blockBuffer: CMBlockBuffer? let alignedData = UnsafeMutableRawPointer.allocate(byteCount: data.count, alignment: MemoryLayout<UInt8>.alignment) data.copyBytes(to: alignedData.assumingMemoryBound(to: UInt8.self), count: data.count) let blockStatus = CMBlockBufferCreateWithMemoryBlock( allocator: kCFAllocatorDefault, memoryBlock: alignedData, blockLength: data.count, blockAllocator: nil, customBlockSource: nil, offsetToData: 0, dataLength: data.count, flags: 0, blockBufferOut: &blockBuffer ) guard blockStatus == kCMBlockBufferNoErr, let validBlockBuffer = blockBuffer else { alignedData.deallocate() throw NSError() } var sampleBuffer: CMSampleBuffer? var timing = [calculateTiming(for: segment)] var sampleSizes = [data.count] let sampleStatus = CMSampleBufferCreate( allocator: kCFAllocatorDefault, dataBuffer: validBlockBuffer, dataReady: true, makeDataReadyCallback: nil, refcon: nil, formatDescription: formatDescription, sampleCount: 1, sampleTimingEntryCount: 1, sampleTimingArray: &timing, sampleSizeEntryCount: sampleSizes.count, sampleSizeArray: &sampleSizes, sampleBufferOut: &sampleBuffer ) guard sampleStatus == noErr else { alignedData.deallocate() throw NSError() } return sampleBuffer } private func decodeSampleBuffer(_ sampleBuffer: CMSampleBuffer) throws { guard let formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer) else { throw NSError() } if decompressionSession == nil { try setupDecompressionSession(formatDescription: formatDescription) } guard let session = decompressionSession else { throw NSError() } let flags: VTDecodeFrameFlags = [._EnableAsynchronousDecompression, ._EnableTemporalProcessing] var flagOut = VTDecodeInfoFlags() let status = VTDecompressionSessionDecodeFrame( session, sampleBuffer: sampleBuffer, flags: flags, frameRefcon: nil, infoFlagsOut: nil) if status != noErr { throw NSError() } } private func setupDecompressionSession(formatDescription: CMFormatDescription) throws { self.formatDescription = formatDescription if let session = decompressionSession { VTDecompressionSessionInvalidate(session) self.decompressionSession = nil } var decompressionSession: VTDecompressionSession? var callback = VTDecompressionOutputCallbackRecord( decompressionOutputCallback: decompressionOutputCallback, decompressionOutputRefCon: Unmanaged.passUnretained(self).toOpaque()) let status = VTDecompressionSessionCreate( allocator: kCFAllocatorDefault, formatDescription: formatDescription, decoderSpecification: nil, imageBufferAttributes: nil, outputCallback: &callback, decompressionSessionOut: &decompressionSession ) if status != noErr { throw NSError() } self.decompressionSession = decompressionSession } let decompressionOutputCallback: VTDecompressionOutputCallback = { ( decompressionOutputRefCon, sourceFrameRefCon, status, infoFlags, imageBuffer, presentationTimeStamp, presentationDuration ) in guard status == noErr else { print("Callback: \(status)") return } if let imageBuffer = imageBuffer { } }
1
0
1.2k
Dec ’24
mediastreamvalidator + hlsreport - Meaning of the "Discontinuity information"
Hi, I ran mediastreamvalidator and hlsreport for the first time and if the "issues" (MUST and SHOULD) sentence are perfectly understandable, I was wondering the meaning of the 2 tables at the end of the report .... in a "Discontinuity Information" section there is 2 table called "discontinuity duration table " and "start time table" is there any documentation on that ? is it a symptom of an issue with the CMAF MP4 file created by thye packager I use ? thanks for your help
1
0
955
Jun ’22
I cannot apply for a FPS certificate
I filled out the FPS certificate application form for existing applications twice in https://developer.apple.com/contact/fps/. After successful submission, I will say that I need to receive email in my mailbox, but I have not received the corresponding notification email in my mailbox. How do I deal with it? thank you!
1
0
988
May ’23
Issue playing HLS (m3u8) live stream
Has anyone else had issues live streaming HLS on XCode 14.3? I am using an IOS 16.2 simulator as it seems the bugs with streaming on the 16.4 simulators still haven't been resolved. I have been able to play on-demand videos fine, although when I try and play a live stream, I just get a black screen with a play button with a cross through it.
1
1
1.4k
May ’23
tsrecompressor (LL-HLS) input file option & 4K source
Now I'm preparing LL-HLS demonstration by using HLS tools. Generated pattern and screen capture are okay. But input file option does not work. Please check whether it's possible to use explicit input file as source. In case of screen recording, the max resolution of multi variant manifest is FHD even though the display resolution is 3840x2160. Please check whether it's possible to set 4K UHD resolution.
1
0
680
Apr ’24
How to satisfy 192 kbit/s variant requirement for video?
Apple's HLS Authoring Requirements states "Primary playlists that are delivered over cellular networks MUST contain a variant whose peak BANDWIDTH is less than or equal to 192 kbit/s" Note the lowest available bitrate in Compressor is 300 kbps. I realize the one way to achieve a 192 kbps target is to use an audio-only track, but how are folks meeting this requirement for HLS applications which require video?
1
0
1.1k
Nov ’21
CoreMediaErrorDomain : code : -16012
Hi , We are getting big spikes of errors on very few programs in some live channels. [-16012:CoreMediaErrorDomain] [Error Domain=CoreMediaErrorDomain Code=-16012 "(null)"] When this error occurred , AVPlayer stops & users has to restart the playback. This is the error we are getting & this happens in some live programs. We have the same set up & uses same transcoders etc in all programs. Mostly we have very low error rate in player with live programs , but with this error , error rate can increase up to 80% of the users effecting pretty much all the users on apple devices. Does anyone know what this error actually means ? What is the context & what is the reason behind that ? It seems like this may be related subtitles & this occurs only when the subtitles are enabled. ( The subtitles are not embedded in the stream it is teletext ) Try to find in apple documents & online & nothing could be find unfortunately.
1
0
3k
Oct ’23
Error 16833 and 19152
We have created a hls playback framework and lot of our client's are complaining about this error {"code": -19152, "domain": "CoreMediaErrorDomain", "localizedDescription": "The operation couldn’t be completed. (CoreMediaErrorDomain error -19152 - The operation couldn’t be completed. (CoreMediaErrorDomain error -19152.))", "localizedFailureReason": "", "localizedRecoverySuggestion": ""} We are unable to reproduce this issue on our end but we have data reflecting the same error happening at good rate. Any help/hint is welcome. Thanks
1
0
2k
Jun ’23
Playing clear-key DRM protected video with AVFoundation
I’m wondering if there is any way to play a clear-key DRM-protected video stream. I have {"clear-key-id": "clear-key"} pair, but I don’t know how to do it in code. It is not FairPlay Streaming nor Widevine. I override resourceLoader(_:shouldWaitForLoadingOfRequestedResource:) and done something similar to this: let key = "{\"key\": \"452948404d635166546a576e5a723475\",\"keyId\": \"2f423f4528482b4d6251655468576d5a\"}" let keyData = Data(key.utf8) loadingRequest.contentInformationRequest?.contentType = AVStreamingKeyDeliveryPersistentContentKeyType loadingRequest.contentInformationRequest?.isByteRangeAccessSupported = true loadingRequest.contentInformationRequest?.contentLength = Int64(keyData.count) loadingRequest.dataRequest?.respond(with: keyData) loadingRequest.finishLoading() I do not think this is the correct way to do it, as I arbitrarily loaded the key as a raw string and compressed it to Data type. I think there should be some API or func to call for that clear-key-based DRM.
Replies
0
Boosts
0
Views
1.5k
Activity
Feb ’23
Does FairPlay work for iPad on iOS 15.4 ?
Website serving Apple FairPlay videos here... I have three users reporting problems with playback using Safari on iPad with iOS 15.4. It seems they can no longer use Chrome (where we serve the same videos using DASH+CENC) either. That is all I know at this time. Not finding anything from google except the 15.1 FairPlay debacle... Just fishing. Anything similar for anyone else? Thank you kindly.
Replies
1
Boosts
0
Views
1.1k
Activity
Mar ’22
HLS EVENT Manifest Safari Player Timeline crash
We have implemented an optimization feature for HLS VOD streaming in the form of an EVENT Manifest. General manifest hour The bottom line is that on the first request, we return the HLS EVENT Manifest within 30 seconds and launch certain processin mechanisms in the background, as soon as everything has ready, on the next requests we return an EVENT Manifest with an EXT-X-ENDLIST tag What does it look like 1st request: #EXTM3U #EXT-X-PLAYLIST-TYPE: EVENT 1.ts 2.ts 3.ts 2nd req (if background completed) #EXTM3U #EXT-X-PLAYLIST-TYPE: EVENT 1.ts 2.ts 3.ts .... .... .... 1000.ts #EXT-X-ENDLIST This approach worked in VLC player and hls.js players but this thing doesn't work in native Safari player It has very strange behavior: Live is shown first in the timeline (which is okay) then, as he has already downloaded the manifest with EXT-X-ENDLIST, it shows the real duration (hour) but literally after 2 seconds it cuts the timeline and leaves only 2 minutes in the timeline by DevTools-> Network, I see that it stops downloading after 8-9 segments And now I would like to know if anyone has encountered such a safari problem and if maybe you need to somehow reconfigure the browser player.
Replies
1
Boosts
0
Views
1.1k
Activity
May ’23
Mediastreamvalidator Error: Invalid URL
I try to validate low latency HLS fragmented MP4 setup with meadistreamvalidator. I get following error: Error: Invalid URL Detail: '(null)' is not a valid URL Source: mediaplaylistURL.m3u8 - segmentURL.mp4 meadistreamvalidator version is 1.23.14 What does that error mean?
Replies
1
Boosts
0
Views
437
Activity
Dec ’24
Use AVPlayer for multiple videos
I'm developing a tutorial style tvOS app with multiple videos. The examples I've seen so far deal with only one video. Defining the player and source(url) before body view let avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../video.mp4")!)) and then in the body view the video is displayed VideoPlayer(player: avPlayer) This allows options such as stop/start etc. When I try something similar with a video title passed into this view I can't define the player with this title variable. var vTitle: String var avPlayer = AVPlayer(url: URL(string: "https://domain.com/.../.../" + vTitle + ".mp4"")!)) var body: some View { I het an error that vTitle can't be used in the url above the body view. Any thoughts or suggestions? Thanks
Replies
1
Boosts
0
Views
1.3k
Activity
Dec ’24
SCTE-35 markers events on Safari
Hello,When streaming and playing HLS streams on Safari using &lt;video&gt; tag, is there way to be notified at application level (javascript) of the presence of SCTE-35 data ranges in the stream (playlist)?When using the &lt;video&gt; tag on Safari, it is the responsibility of the the native video element to download and parse the playlists, thus there is no way for web application to know about the presence of such tags/markers in the playlists.Does the native video element trigger some events (like cue events for example) to signal the presence of these SCTE-35 data ranges?I tried to listen for cue events but unsuccessfully.
Replies
1
Boosts
0
Views
1.6k
Activity
Jun ’23
How do I access a FairPlay protected stream's frame in avplayer?
when i played a fairplay streaming by avplayer,calling copyPixelBufferForItemTime on AVPlayerItemVideoOutput the pixelbuffer returns NULL.is there any way to get the pixel buffer from a stream that is protected using FairPlay on iOS or apple's APIs in order to display FairPlay stream on an OpenGL texture in 3D space?
Replies
1
Boosts
0
Views
721
Activity
Mar ’23
HLS black screen on all ios devices
Our custom software takes RTSP from cctv cameras and turns it into an RTSP stream that we play through calppr player. One particular model of camera wont play on ios devices. It is just all black when trying to play it. on ios (all versions of ios) It still works great on PC, Mac, and Android. Our hls stream is video only. There is no audio. The problem is not with the player because I tested other players and they do the same thing on iOS. Black screen or at best they freeze on the first picture and don't ever move. Any advice on what the problem may be? Thank you so much!
Replies
1
Boosts
0
Views
1.9k
Activity
Jun ’22
Fairplay error on MacOS catalyst
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:] &lt;&lt;&lt;&lt; FigPKDKeyManager &gt;&gt;&gt;&gt; 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] &lt;&lt;&lt;&lt; FigStreamPlayer &gt;&gt;&gt;&gt; fpfs_ensureDecryptorHasStarted: [0x7fc44e4dc520|P/NW] &lt;0x7fc44fa44000|I/SRA.01&gt;: track 1 latching decryptorFailure -42650 85505 0 teachonline: (MediaToolbox) [com.apple.coremedia:player] &lt;&lt;&lt;&lt; FigStreamPlayer &gt;&gt;&gt;&gt; fpfs_StopPlayingItem: [0x7fc44e4dc520|P/NW] &lt;0x7fc44fa44000|I/SRA.01&gt;: 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.
Replies
1
Boosts
1
Views
967
Activity
Dec ’24
iOS 15: AVPlayer stays on lowest quality HLS Stream
Is anyone encountering an issue where their HLS files are no longer working with iOS 15 AVPlayer? We are seeing the player stay on the lowest quality variant (that is the lowest bit rate HLS option) for about a minute before changing to the highest quality, despite being on a great network connection throughout. This is reproducible on an isolated project with nothing but the the AVPLayer loading a m3u8 URL. We have not been able to find anything about AVPlayer that changed or would cause this in iOS 15. Are we missing anything? Also - We have been trying to locate an HLS example for audio that also passes the Apple HLS validator - does anyone know where that can be found? We did not have luck with the examples on Apple's developer site as they are out of date with the validator it seems like. We thought that maybe there's an issue with our HLS streams despite them working before sub iOS 15. But it's tough to find a good example of anything that passes the validator. Any input would be awesome, thank you!
Replies
1
Boosts
0
Views
1.3k
Activity
Nov ’21
iOS Radio App: Need to extract and stream audio-only from HLS streams with video content
I'm developing an iOS radio app that plays various HLS streams. The challenge is that some stations broadcast HLS streams containing both audio and video (example: https://svs.itworkscdn.net/smcwatarlive/smcwatar/chunks.m3u8), but I want to: Extract and play only the audio track Support AirPlay for audio-only streaming Minimize data usage by not downloading video content Technical Details: iOS 17+ Swift 5.9 Using AVFoundation for playback Current implementation uses AVPlayer with AVPlayerItem Current Code Structure: class StreamPlayer: ObservableObject { @Published var isPlaying = false private var player: AVPlayer? private var playerItem: AVPlayerItem? func playStream(url: URL) { let asset = AVURLAsset(url: url) playerItem = AVPlayerItem(asset: asset) player = AVPlayer(playerItem: playerItem) player?.play() } Stream Analysis: When analyzing the video stream using FFmpeg: CopyInput #0, hls, from 'https://svs.itworkscdn.net/smcwatarlive/smcwatar/chunks.m3u8': Stream #0:0: Video: h264, yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps Stream #0:1: Audio: aac, 44100 Hz, stereo, fltp Attempted Solutions: Using MobileFFmpeg: let command = [ "-i", streamUrl, "-vn", "-acodec", "aac", "-ac", "2", "-ar", "44100", "-b:a", "128k", "-f", "mpegts", "udp://127.0.0.1:12345" ].joined(separator: " ") ffmpegProcess = MobileFFmpeg.execute(command) Issue: While FFmpeg successfully extracts audio, playback through AVPlayer doesn't work reliably. Tried using HLS output: let command = [ "-i", streamUrl, "-vn", "-acodec", "aac", "-ac", "2", "-ar", "44100", "-b:a", "128k", "-f", "hls", "-hls_time", "2", "-hls_list_size", "3", outputUrl.path ] Issue: Creates temporary files but faces synchronization issues with live streams. Requirements: Real-time audio extraction from HLS stream Maintain live streaming capabilities Full AirPlay support Minimal data usage (avoid downloading video content) Handle network interruptions gracefully Questions: What's the most efficient way to extract only audio from an HLS stream in real-time? Is there a way to tell AVPlayer to ignore video tracks completely? Are there better alternatives to FFmpeg for this specific use case? What's the recommended approach for handling AirPlay with modified streams? Any guidance or alternative approaches would be greatly appreciated. Thank you!
Replies
1
Boosts
1
Views
630
Activity
Dec ’24
Decode HLS livestream with VideoToolbox
Hi, I'm trying to decode a HLS livestream with VideoToolbox. The CMSampleBuffer is successfully created (OSStatus == noErr). When I enqueue the CMSampleBuffer to a AVSampleBufferDisplayLayer the view isn't displaying anything and the status of the AVSampleBufferDisplayLayer is 1 (rendering). When I use a VTDecompressionSession to convert the CMSampleBuffer to a CVPixelBuffer the VTDecompressionOutputCallback returns a -8969 (bad data error). What do I need to fix in my code? Do I incorrectly parse the data from the segment for the CMSampleBuffer? let segmentData = try await downloadSegment(from: segment.url) let (sps, pps, idr) = try parseH264FromTSSegment(tsData: segmentData) if self.formatDescription == nil { self.formatDescription = try CMFormatDescription(h264ParameterSets: [sps, pps]) } if let sampleBuffer = try createSampleBuffer(from: idr, segment: segment) { try self.decodeSampleBuffer(sampleBuffer) } func parseH264FromTSSegment(tsData: Data) throws -> (sps: Data, pps: Data, idr: Data) { let tsSize = 188 var pesData = Data() for i in stride(from: 0, to: tsData.count, by: tsSize) { let tsPacket = tsData.subdata(in: i..<min(i + tsSize, tsData.count)) guard let payload = extractPayloadFromTSPacket(tsPacket) else { continue } pesData.append(payload) } let nalUnits = parseNalUnits(from: pesData) var sps: Data? var pps: Data? var idr: Data? for nalUnit in nalUnits { guard let firstByte = nalUnit.first else { continue } let nalType = firstByte & 0x1F switch nalType { case 7: // SPS sps = nalUnit case 8: // PPS pps = nalUnit case 5: // IDR idr = nalUnit default: break } if sps != nil, pps != nil, idr != nil { break } } guard let validSPS = sps, let validPPS = pps, let validIDR = idr else { throw NSError() } return (validSPS, validPPS, validIDR) } func extractPayloadFromTSPacket(_ tsPacket: Data) -> Data? { let syncByte: UInt8 = 0x47 guard tsPacket.count == 188, tsPacket[0] == syncByte else { return nil } let payloadStart = (tsPacket[1] & 0x40) != 0 let adaptationFieldControl = (tsPacket[3] & 0x30) >> 4 var payloadOffset = 4 if adaptationFieldControl == 2 || adaptationFieldControl == 3 { let adaptationFieldLength = Int(tsPacket[4]) payloadOffset += 1 + adaptationFieldLength } guard adaptationFieldControl == 1 || adaptationFieldControl == 3 else { return nil } let payload = tsPacket.subdata(in: payloadOffset..<tsPacket.count) return payloadStart ? payload : nil } func parseNalUnits(from h264Data: Data) -> [Data] { let startCode = Data([0x00, 0x00, 0x00, 0x01]) var nalUnits: [Data] = [] var searchRange = h264Data.startIndex..<h264Data.endIndex while let range = h264Data.range(of: startCode, options: [], in: searchRange) { let nextStart = h264Data.range(of: startCode, options: [], in: range.upperBound..<h264Data.endIndex)?.lowerBound ?? h264Data.endIndex let nalUnit = h264Data.subdata(in: range.upperBound..<nextStart) nalUnits.append(nalUnit) searchRange = nextStart..<h264Data.endIndex } return nalUnits } private func createSampleBuffer(from data: Data, segment: HLSSegment) throws -> CMSampleBuffer? { var blockBuffer: CMBlockBuffer? let alignedData = UnsafeMutableRawPointer.allocate(byteCount: data.count, alignment: MemoryLayout<UInt8>.alignment) data.copyBytes(to: alignedData.assumingMemoryBound(to: UInt8.self), count: data.count) let blockStatus = CMBlockBufferCreateWithMemoryBlock( allocator: kCFAllocatorDefault, memoryBlock: alignedData, blockLength: data.count, blockAllocator: nil, customBlockSource: nil, offsetToData: 0, dataLength: data.count, flags: 0, blockBufferOut: &blockBuffer ) guard blockStatus == kCMBlockBufferNoErr, let validBlockBuffer = blockBuffer else { alignedData.deallocate() throw NSError() } var sampleBuffer: CMSampleBuffer? var timing = [calculateTiming(for: segment)] var sampleSizes = [data.count] let sampleStatus = CMSampleBufferCreate( allocator: kCFAllocatorDefault, dataBuffer: validBlockBuffer, dataReady: true, makeDataReadyCallback: nil, refcon: nil, formatDescription: formatDescription, sampleCount: 1, sampleTimingEntryCount: 1, sampleTimingArray: &timing, sampleSizeEntryCount: sampleSizes.count, sampleSizeArray: &sampleSizes, sampleBufferOut: &sampleBuffer ) guard sampleStatus == noErr else { alignedData.deallocate() throw NSError() } return sampleBuffer } private func decodeSampleBuffer(_ sampleBuffer: CMSampleBuffer) throws { guard let formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer) else { throw NSError() } if decompressionSession == nil { try setupDecompressionSession(formatDescription: formatDescription) } guard let session = decompressionSession else { throw NSError() } let flags: VTDecodeFrameFlags = [._EnableAsynchronousDecompression, ._EnableTemporalProcessing] var flagOut = VTDecodeInfoFlags() let status = VTDecompressionSessionDecodeFrame( session, sampleBuffer: sampleBuffer, flags: flags, frameRefcon: nil, infoFlagsOut: nil) if status != noErr { throw NSError() } } private func setupDecompressionSession(formatDescription: CMFormatDescription) throws { self.formatDescription = formatDescription if let session = decompressionSession { VTDecompressionSessionInvalidate(session) self.decompressionSession = nil } var decompressionSession: VTDecompressionSession? var callback = VTDecompressionOutputCallbackRecord( decompressionOutputCallback: decompressionOutputCallback, decompressionOutputRefCon: Unmanaged.passUnretained(self).toOpaque()) let status = VTDecompressionSessionCreate( allocator: kCFAllocatorDefault, formatDescription: formatDescription, decoderSpecification: nil, imageBufferAttributes: nil, outputCallback: &callback, decompressionSessionOut: &decompressionSession ) if status != noErr { throw NSError() } self.decompressionSession = decompressionSession } let decompressionOutputCallback: VTDecompressionOutputCallback = { ( decompressionOutputRefCon, sourceFrameRefCon, status, infoFlags, imageBuffer, presentationTimeStamp, presentationDuration ) in guard status == noErr else { print("Callback: \(status)") return } if let imageBuffer = imageBuffer { } }
Replies
1
Boosts
0
Views
1.2k
Activity
Dec ’24
mediastreamvalidator + hlsreport - Meaning of the "Discontinuity information"
Hi, I ran mediastreamvalidator and hlsreport for the first time and if the "issues" (MUST and SHOULD) sentence are perfectly understandable, I was wondering the meaning of the 2 tables at the end of the report .... in a "Discontinuity Information" section there is 2 table called "discontinuity duration table " and "start time table" is there any documentation on that ? is it a symptom of an issue with the CMAF MP4 file created by thye packager I use ? thanks for your help
Replies
1
Boosts
0
Views
955
Activity
Jun ’22
I cannot apply for a FPS certificate
I filled out the FPS certificate application form for existing applications twice in https://developer.apple.com/contact/fps/. After successful submission, I will say that I need to receive email in my mailbox, but I have not received the corresponding notification email in my mailbox. How do I deal with it? thank you!
Replies
1
Boosts
0
Views
988
Activity
May ’23
Issue playing HLS (m3u8) live stream
Has anyone else had issues live streaming HLS on XCode 14.3? I am using an IOS 16.2 simulator as it seems the bugs with streaming on the 16.4 simulators still haven't been resolved. I have been able to play on-demand videos fine, although when I try and play a live stream, I just get a black screen with a play button with a cross through it.
Replies
1
Boosts
1
Views
1.4k
Activity
May ’23
tsrecompressor (LL-HLS) input file option & 4K source
Now I'm preparing LL-HLS demonstration by using HLS tools. Generated pattern and screen capture are okay. But input file option does not work. Please check whether it's possible to use explicit input file as source. In case of screen recording, the max resolution of multi variant manifest is FHD even though the display resolution is 3840x2160. Please check whether it's possible to set 4K UHD resolution.
Replies
1
Boosts
0
Views
680
Activity
Apr ’24
How to satisfy 192 kbit/s variant requirement for video?
Apple's HLS Authoring Requirements states "Primary playlists that are delivered over cellular networks MUST contain a variant whose peak BANDWIDTH is less than or equal to 192 kbit/s" Note the lowest available bitrate in Compressor is 300 kbps. I realize the one way to achieve a 192 kbps target is to use an audio-only track, but how are folks meeting this requirement for HLS applications which require video?
Replies
1
Boosts
0
Views
1.1k
Activity
Nov ’21
CoreMediaErrorDomain : code : -16012
Hi , We are getting big spikes of errors on very few programs in some live channels. [-16012:CoreMediaErrorDomain] [Error Domain=CoreMediaErrorDomain Code=-16012 "(null)"] When this error occurred , AVPlayer stops & users has to restart the playback. This is the error we are getting & this happens in some live programs. We have the same set up & uses same transcoders etc in all programs. Mostly we have very low error rate in player with live programs , but with this error , error rate can increase up to 80% of the users effecting pretty much all the users on apple devices. Does anyone know what this error actually means ? What is the context & what is the reason behind that ? It seems like this may be related subtitles & this occurs only when the subtitles are enabled. ( The subtitles are not embedded in the stream it is teletext ) Try to find in apple documents & online & nothing could be find unfortunately.
Replies
1
Boosts
0
Views
3k
Activity
Oct ’23
Error 16833 and 19152
We have created a hls playback framework and lot of our client's are complaining about this error {"code": -19152, "domain": "CoreMediaErrorDomain", "localizedDescription": "The operation couldn’t be completed. (CoreMediaErrorDomain error -19152 - The operation couldn’t be completed. (CoreMediaErrorDomain error -19152.))", "localizedFailureReason": "", "localizedRecoverySuggestion": ""} We are unable to reproduce this issue on our end but we have data reflecting the same error happening at good rate. Any help/hint is welcome. Thanks
Replies
1
Boosts
0
Views
2k
Activity
Jun ’23