[iOS]AVPlayerItemVideoOutput.hasNewPixelBufferForItemTime doesn't work correctly

后端 未结 3 1868
轮回少年
轮回少年 2021-02-08 05:16

It\'s my first question here, so don\'t be severe.

I\'m playing video from the net using AVPlayer. I output the current frame using AVPlayerItemVideoOutput

3条回答
  •  故里飘歌
    2021-02-08 06:14

    I noticed that AVPlayerItemVideoOutput "jams" somehow when using HLS multibitrate playlists. When player changes to higher bitrate -> trackid of playeritems video track changes -> it will got few pixelbuffers but after that hasNewPixelBufferForItemTime will return NO always.

    I have spent days with this problem. Accidentally I noticed that if I go to background and after that back to foreground -> Video will play normally with higher bitrate. This is not the solution.

    Finally I found workaround to this problem. I set counter for failed pixelbuffers, after 100 fails I remove current output from playeritem and set same instance back.

    if (failedCount > 100)
        {
            failedCount = 0;
            [_playerItem removeOutput:_output];
            [_playerItem addOutput:_output];
        }
    

提交回复
热议问题