在iOS中反转视频播放 [英] Reverse video playback in iOS

查看:628
本文介绍了在iOS中反转视频播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在AVPlayer中向后播放视频。我已经尝试将rate属性更改为-1.0,尽管它确实有效,但它并不顺利。有什么方法可以顺利地向后播放视频吗?

I want to play video backward in AVPlayer. I have tried with changing rates property to -1.0, and although it did work it was not smooth. Is there any way through which I can smoothly play videos backward?

推荐答案

如评论中所述,问题在于关键帧和事实上大多数编解码器都不是为了向后播放而设计的。重新编码视频有2个选项,不需要您在编辑时实际反转视频。

As stated in the comments, the problem is with keyframes and the fact that most codecs are not designed to play backwards. There are 2 options for re-encoding the video that doesn't require you to actually reverse the video in editing.


  1. 使每一帧都成为关键帧。我已经看到这种方法适用于依赖于关键帧的H.264等编解码器。基本上,如果每个帧都是关键帧,那么每个帧都可以在不依赖任何先前帧的情况下进行解码,因此它实际上与向前播放相同。

  2. 使用不使用关键帧的编解码器和非关键帧(基本上所有帧都是关键帧)。 PhotoJPEG是一个这样的选择,虽然我不完全确定它是否在iOS上播放。我想是的。它适用于Mac。

请注意,与典型的关键帧每x帧相比,此选项中的任何一个都会导致更大的文件大小编码视频。

Note that either of this options will result in larger file sizes compared to typical "keyframe every x frames" encoded video.

这篇关于在iOS中反转视频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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