简体   繁体   English

MPMovieplayerController playableDuration随m3u8文件而波动

[英]MPMovieplayerController playableDuration fluctuating for m3u8 files

I am buffering a video which is in the m3u8 format and I am setting this url as the contenturl for MPMovieplayerController 我正在缓冲m3u8格式的视频,并将此URL设置为MPMovieplayerController的contenturl

I am running a background thread that runs every 0.3 seconds which I use to check the buffered and played duration and perform the check accordingly 我正在运行一个每0.3秒运行一次的后台线程,该线程用于检查缓冲和播放的持续时间并相应地执行检查

if(!mPlaybackProgressTimer)
    mPlaybackProgressTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(didPlayback:) userInfo:nil repeats:YES] retain];

and in didplayback 并在didplayback中

.. ..

- (void)didPlayback:(id)sender {

    NSTimeInterval totalDuration = [mVideoPlayerController duration];

    NSTimeInterval playbackTime = [mVideoPlayerController currentPlaybackTime];
    float playbackProgress = 0.0;

   if(playbackTime > 0.0 && totalDuration > 0.0)
       playbackProgress = playbackTime / totalDuration;

   mPercentWatched = round(100 * playbackProgress);

   NSTimeInterval bufferedTime = [mVideoPlayerController playableDuration];
   float bufferProgress = 0.0;

   if(playbackTime > 0.0 && totalDuration > 0.0)
       bufferProgress = bufferedTime / totalDuration;

   [self setProgress:bufferProgress forProgressType:eProgressTypeBuffer];
   [self setProgress:playbackProgress forProgressType:eProgressTypePlay];
}

The problem is that the bufferedTime is fluctuating under certain circumstances :- 问题是在某些情况下bufferedTime会波动:
- I the m3u8 files divided into separate files for different resolutions and bitrates -我将m3u8文件分为不同的文件,以实现不同的分辨率和比特率
- I have an index.m3u8 file which dicides which m3u8 file to serve for what bandwidth -我有一个index.m3u8文件,该文件指示要为哪个带宽提供服务的m3u8文件
- Of course it does not serve up the whole m3u8 file but individual *.ts files based on how the user will have the best experience without any delay (all this is managed internally) - Also i have followed all this in accordance with the apple developer guidelines -当然,它不会提供整个m3u8文件,而是基于用户如何获得最佳体验而没有任何延迟的单独* .ts文件(所有这些都在内部进行管理)-此外,我也按照苹果的做法进行了跟踪开发人员指南

I'm not sure why the fluctuation is happening but what seems to make sense to me is that .. certain amount of data is buffered but then i think that data may be being discarded (just a theory) 我不确定为什么会发生波动,但对我来说似乎有意义的是..缓冲了一定数量的数据,但随后我认为数据可能会被丢弃(只是一个理论)

Note: I am using encoding.com to segment the media 注意:我正在使用encoding.com细分媒体

UPDATE: Logs 更新:日志

2013-01-14 11:46:57.731 IronStudios[7724:c07] Buffer Progress : 0.139779 2013-01-14 11:46:57.731 IronStudios [7724:c07]缓冲区进度:0.139779
2013-01-14 11:46:57.930 IronStudios[7724:c07] Buffer Progress : 0.139779 2013-01-14 11:46:57.930 IronStudios [7724:c07]缓冲区进度:0.139779
2013-01-14 11:46:58.130 IronStudios[7724:c07] Buffer Progress : 0.139790 2013-01-14 11:46:58.130 IronStudios [7724:c07]缓冲区进度:0.139790
2013-01-14 11:46:58.331 IronStudios[7724:c07] Buffer Progress : 0.139790 2013-01-14 11:46:58.331 IronStudios [7724:c07]缓冲区进度:0.139790
2013-01-14 11:46:58.530 IronStudios[7724:c07] Buffer Progress : 0.125042 2013-01-14 11:46:58.530 IronStudios [7724:c07]缓冲区进度:0.125042
2013-01-14 11:46:58.730 IronStudios[7724:c07] Buffer Progress : 0.126391 2013-01-14 11:46:58.730 IronStudios [7724:c07]缓冲区进度:0.126391
2013-01-14 11:46:58.930 IronStudios[7724:c07] Buffer Progress : 0.124450 2013-01-14 11:46:58.930 IronStudios [7724:c07]缓冲区进度:0.124450
2013-01-14 11:46:59.130 IronStudios[7724:c07] Buffer Progress : 0.125799 2013-01-14 11:46:59.130 IronStudios [7724:c07]缓冲区进度:0.125799

as you can see the buffer progress is reducing on certain instances. 如您所见,某些实例的缓冲区进度正在减少。

The duration could be derived from the amount downloaded, whereas the playableDuration is derived from what can be played back. 持续时间可以从下载的数量中得出,而playableDuration从可以播放的内容中得出。

iOS will only start playback of a mpeg2-ts chunk once the entire chunk has been downloaded. 一旦下载了整个块,iOS才会开始播放mpeg2-ts块。

Suppose you're using 10 second chunks. 假设您正在使用10秒块。

Downloaded: 2.2 chunks (22 seconds)
Playable:   2   chunks (20 seconds)
Progress bar = 2 / 2.2 = ~91%

A couple of seconds later.... 几秒钟后...

Downloaded: 2.9 chunks (29 seconds)
Playable:   2   chunks (20 seconds)
Progress bar = 2 / 2.9 = ~69%

Your progress bar has gone backwards... 您的进度条向后退了...

A couple of seconds later.... 几秒钟后...

Downloaded: 3.1 chunks (31 seconds)
Playable:   3   chunks (30 seconds)
Progress bar = 3 / 3.1 = ~97%

and forwards again... 然后再次转发...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM