I'm a new iOS developer, I'm working on a video player app for a video sharing site, where sometimes a recording consists of two video streams (one showing the presenter, the other showing the recording of his screen). I'm trying to play this second video with AVFoundation, creating an AVPlayer. With some videos it works very well, but with some others it runs out of memory. After lot of investigating I figured that it tries to buffer the whole video into the memory.
I've spent hours googling it, but couldn't find anything.
I created a small project just to demonstrate this: github project. It sets up two AVPlayer's, for two different video streams, and updates the UI to show the loadedTimeRanges of the players' AVPlayerItem. For the first video it only buffers ~60 seconds, which is nice, but for the second video it keeps buffering.
self.player1 = [AVPlayer playerWithURL:url1];
self.player2 = [AVPlayer playerWithURL:url2];
and the two text labels:
self.data1.text = [NSString stringWithFormat:@"Player 1 loadedTimeRanges: %@",
self.player1.currentItem.loadedTimeRanges];
self.data2.text = [NSString stringWithFormat:@"Player 2 loadedTimeRanges: %@",
self.player2.currentItem.loadedTimeRanges];
Maybe this could be important: The over-buffering video does not have an audio track, just a video.
UPDATE: I reproduced the problem with using MPMoviePlayerController instead of AVPlayer, and checking the playableDuration property. With the first movie it stops around 60 seconds, with the second movie it keeps going and then it runs out of memory.
UPDATE2: I got the actual video files and put them up to Dropbox, and tried to stream those: then I don't have the problem! It buffers the whole movie, but it does not run out of memory. It only runs out of memory if I stream them from the original site (our video sharing site). The URLs are there in the github project.
I'm really looking forward to any hints what could cause this.
Thank you!
http://stream.videotorium.hu:1935/vtorium/_definst_/mp4:705/3705/3705_3571_content_hq.mp4/playlist.m3u8?sessionid=cp8dl757mvqukp0bsoflhd79s0_3705
, if I curl it, I get an m3u which contains one other URL, if I curl that, I get an m3u with hundreds of URLs likemedia_1.ts?wowzasessionid=530673462&sessionid=cp8dl757mvqukp0bsoflhd79s0_3705
. Does that mean that the server side is sending the proper stream? – zsombornagy