AVPlayer throwing : "Internal error: restarting too far ahead"

AVPlayer throwing : "Internal error: restarting too far ahead"

我正在观察 AVPlayer 的 KVO AVPlayerItemNewErrorLogEntryNotification,发现以下错误:

我无法理解下面这行的真正含义。

"Internal error: restarting too far ahead"

任何人都可以帮我找到这个问题的根本原因。

If long .ts video file respons with: -12645.

没有关于 MPMediaPlayer 在 MPMovieErrorLogEvent 中返回的错误状态代码的文档 class。 但其中一些是:

HTTP status - errorStatusCode - errorDomain - errorComment

400     -12666  CoreMediaErrorDomain    unrecognized http response 400  
401     -12937  CoreMediaErrorDomain    Authentication Error    
402     -12666  CoreMediaErrorDomain    unrecognized http response 402  
403     -12660  CoreMediaErrorDomain    HTTP 403: Forbidden     
404     -12938  CoreMediaErrorDomain    HTTP 404: File not found    
405     -12666  CoreMediaErrorDomain    unrecognized http response 405  
406     -12666  CoreMediaErrorDomain    unrecognized http response 406  
407     -12937  CoreMediaErrorDomain    Authentication Error    
409     -12666  CoreMediaErrorDomain    unrecognized http response 409  
...                 
415     -12666  CoreMediaErrorDomain    unrecognized http response 415  

500     -12666  CoreMediaErrorDomain    unrecognized http response 500  
501     -12666  CoreMediaErrorDomain    unrecognized http response 501  
502     -12666  CoreMediaErrorDomain    unrecognized http response 502  
503     -12661  CoreMediaErrorDomain    HTTP 503: Unavailable   
504     -12666  CoreMediaErrorDomain    unrecognized http response 504  
505     -12666  CoreMediaErrorDomain    unrecognized http response 505  

if long .ts video file respons  -12645  CoreMediaErrorDomain    No response for media file in 10 s  

video .ts file bitrate differ from m3u8 declaration     -12318  CoreMediaErrorDomain    Segment exceeds specified bandwidth for variant     

for live stream.playlist m3u8 did not change too long   -12642  CoreMediaErrorDomain    Playlist File unchanged for 2 consecutive reads     

if wrong host ip    -1004   kCFErrorDomainCFNetwork     -   

if wrong dns host name  -1003   kCFErrorDomainCFNetwork     -   

if bad formatted URL    -1000   kCFErrorDomainCFNetwork     -   

if invalid https/ssl request    -1202   kCFErrorDomainCFNetwork     -

根据 Apple 员工的说法,此错误消息意味着:

The player is complaining that it was trying to restart a live stream, but only had 1.4 seconds of material available. How many segments are in your live playlist? These days we recommend that you always have at least six segments in the playlist. I believe the only effect is to delay palyback until it has enough data.

来源:https://forums.developer.apple.com/thread/40791


错误的原因很可能是m3u8本身。

流式传输直播节目(例如任何电视频道)时,事件数据的可用性与编码器创建媒体片段 (.ts) 然后附加到播放列表之间存在延迟。

我可以想象,如果 playerItem 播放头的位置位于缓冲区的最边缘,并且新媒体片段在服务器上的可用速度不够快,就会产生这些类型的错误。


是否应在客户端防止或处理这些错误:

由于这些错误被报告为 internal 并且 AVPlayer 显然已从中恢复,因此可以安全地假设它们正在内部处理。因此,它们可以被理解为简单的错误报告,并且可以选择忽略它们。

如果想阻止它们,唯一的方法可能是手动将实时缓冲区的边缘时间倒退几秒钟。