Texture icon indicating copy to clipboard operation
Texture copied to clipboard

[ASVideoNode] Video node does not support HLS video

Open abbasnaqvi200 opened this issue 1 year ago • 2 comments

I encountered an issue with ASVideoNode where it does not handle HLS video streams properly. Instead of streaming the video in chunks (as expected with HLS), it attempts to load the entire video first, leading to significant delays before playback begins, especially on slower internet connections. The behavior is similar to loading an MP4 file, rather than a stream.

// Get the reverse proxy URL let cachedVideoURL = HLSVideoCache.shared.reverseProxyURL(from: vURL) ?? vURL

// Create AVURLAsset let asset = AVURLAsset(url: cachedVideoURL)

// Assign the asset to ASVideoPlayerNode self.videoPlayerNode.videoNode.asset = asset

self.setupPlayer()

func setupPlayer() { if let player = videoPlayerNode.videoNode.player { if player.currentItem?.preferredForwardBufferDuration == 0.0 { player.automaticallyWaitsToMinimizeStalling = true if let currentItem = player.currentItem { currentItem.preferredForwardBufferDuration = 2 currentItem.canUseNetworkResourcesForLiveStreamingWhilePaused = true currentItem.cancelPendingSeeks() currentItem.asset.cancelLoading() } player.playImmediately(atRate: 1.0) player.play() } } }

Expected Behavior: The video should start playing immediately after loading the initial chunks, streaming the rest dynamically as needed (true HLS behavior).

Actual Behavior: The video does not start playing until the entire content is loaded, resulting in long delays before playback begins.

abbasnaqvi200 avatar Dec 12 '24 05:12 abbasnaqvi200

+1

weisttl avatar Mar 07 '25 01:03 weisttl

@abbasnaqvi200 how you are caching HLS streams. I also want to work on similar thing like reels UI and I want to pre-cache HLS streams to play into ASVideoNode. Can you help me in implementing this?

rahul-sysquare avatar Mar 20 '25 12:03 rahul-sysquare