iOS 中流畅的视频循环
谁能建议一种方法,可以在 iOS 中实现完全流畅、无缝的视频剪辑循环?我尝试了两种方法,这两种方法都会在视频循环时产生一个小暂停
1) AVPlayerLayer ,其中playerItemDidReachEnd通知设置为seekToTime:kCMTimeZero
我更喜欢使用AVPlayerLayer(出于其他原因),但此方法会产生大约循环之间有一秒钟。
2) MPMoviePlayerController 与 setRepeatMode:MPMovieRepeatModeOne
这样会导致停顿较小,但仍然不完美。
我不知道从这里该去哪里。有人能建议一个灵魂吗?
Can anyone suggest a method by which you can achieve a completely smooth and seamless looping of a video clip in iOS? I have tried two methods, both of which produce a small pause when the video loops
1) AVPlayerLayer with the playerItemDidReachEnd notification setting off seekToTime:kCMTimeZero
I prefer to use an AVPlayerLayer (for other reasons), but this method produces a noticeable pause of around a second between loops.
2) MPMoviePlayerController with setRepeatMode:MPMovieRepeatModeOne
This results in a smaller pause, but it is still not perfect.
I'm not sure where to go from here. Can anyone suggest a soultion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我同意@SamBrodkin 的发现。
并
为我解决了 iOS 5 上的非循环问题。
I can concur @SamBrodkin's findings.
and
fixed the non-looping issue on iOS 5 for me too.
我刚刚在运行 iOS 5.1.1、基本 SDK iOS 5.1 的 iPad 3 上运行此功能
设置电影播放器时,将重复模式设置为 MPMovieRepeatModeNone
然后添加通知
然后设置您的选择器以在电影播放完毕时进行过滤
Apple 在从 iOS 4 更改为 iOS 5 时对 MPMoviePlayerController 处理加载电影文件的方式进行了一些重大更改,所以我不知道此方法在什么情况下是否有效他们发布了 iOS 6
I just got this working on my iPad 3 running iOS 5.1.1, base SDK iOS 5.1
When setting up the movie player, set the repeat mode to MPMovieRepeatModeNone
then add the notification
Then set up your selector to filter when the movie finishes playing
Apple made some large changes to how the MPMoviePlayerController handles loading movie files when they changed from iOS 4 to iOS 5, so I do not know if this method will work when they release iOS 6
要查看显示背景视频(来自动画 GIF)的无缝循环以及一对前景角色动画(带有 Alpha 通道)之间切换的示例,请查看 ios 上的无缝视频循环。我过去尝试过使用 AVPlayer,但不得不放弃 AVPlayer 相关的解决方案,因为它们效果不够好。另请参阅这个问题 iphone-smooth-transition-from-one-视频到另一个。
To see an example that shows seamless looping of a background video (from an animated GIF) and switching between a pair of foreground character animations (with alpha channel), have a look at seamless-video-looping-on-ios. I tried to use AVPlayer in the past and had to give up on AVPlayer related solutions as they did not work well enough. See this SO question also iphone-smooth-transition-from-one-video-to-another.
我调查了与原始海报报告的相同问题(循环中的小停顿破坏了无缝性)。幸运的是,我有另一个没有这种行为的视频样本,直到后来才找到解释/不同:
音轨。
我怀疑声音初始化非常慢(路由?)。
删除音轨对我来说是最简单的解决方案(不需要声音),但我必须进一步挖掘(音频混合选项并测试已在此线程中发布的解决方案)。
埃里克
I investigated the same problem as reported by the original poster (small pause in the loop that was breaking the seamlessness). By luck I had another video sample that didn't had this behavior and found the explanation/different only later:
The sound track.
I suspect a very slow sound initialisation (routing?).
Removing the sound track was the easiest solution for me (no sound needed) but I will have to dig further (audio mixing options and testing the solution that have been posted in this thread).
Eric
为了避免视频倒带时出现间隙,在合成中使用同一资源的多个副本对我来说效果很好。
To avoid the gap when the video is rewound, using multiple copies of the same asset in a composition worked well for me.