SeekToTime顺畅地工作仅向前,向后冻结 [英] SeekToTime working smoothly just for forwards, freezy on backwards

查看:57
本文介绍了SeekToTime顺畅地工作仅向前,向后冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多帖子,但没有一个有帮助.我的设备上的视频具有不同的FPS(如果有问题的话).我正在计算确切的 CMTime (如果将其转换为秒,则将为10.33333、10.4444等).我正在尝试使用此代码:

I know there is a bunch of posts, but none of them helped. I have videos with different FPS(if it matter somehow) over my device. I'm calculating the exact CMTime (if we translate them to seconds they'll be 10.33333,10.4444 etc'). I'm seeking using this code :

  self.player.seekToTime( time, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)

它只能平稳地向前运行,而不能平滑地向前运行.有什么想法吗?

推荐答案

这是由于压缩视频可与关键帧"一起使用的事实.关键帧是完全渲染的视频帧,但并非每个帧都是关键帧.关键帧之后的帧仅作为与该关键帧的增量差异存储.这意味着,当您向前移动视频时,播放器将显示关键帧,移至下一帧并绘制更改,移至下一帧,依此类推.当向后移动视频时,播放器唯一可以显示的内容是关键帧.通常,它将使用编码后的数据显示关键帧以及关键帧之后的几帧,以便您看到视频在那时的情况.解决此问题的唯一方法是将视频解压缩到缓冲区中并向后进行扫描-出于显而易见的原因,对于大多数用途而言,这太慢了.

This is due to the fact that compressed video works with 'key-frames'. A key frame is an entirely rendered video frame but not every frame is a key frame. Frames that follow a key frame are only stored as the incremental differences from that key frame. This means that when you are moving forward through video the player displays a key frame, moves to the next frame and draws the changes, moves to the next frame, etc, etc. When moving backwards through video the only thing the player can actually display are the key frames. Usually it will use the encoded data to display the key frame plus a few frames AFTER the key frame so you get to see what's happening at that point in the video. The only way around this is to uncompress the video into a buffer and scan backwards through that - for obvious reasons this is too slow for most purposes.

http://www.dacast.com/blog/什么是视频的关键帧/

这篇关于SeekToTime顺畅地工作仅向前,向后冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆