iPhone 从一个视频平滑过渡到另一个视频
我必须找出从一个视频过渡到下一个
基本想法的最佳方法:一个例子是有一个人走路的视频......用户点击视频,视频就会发生无缝过渡 。
我的第一个想法是创建 2 个电影播放器并在 2 个视图元素之间使用过渡 但电影播放器不支持这一点。
停止当前视频,加载新内容,然后启动它是一种解决方案,但不是很优雅。我们正在为我们的代表制作一个交互式销售工具,我们希望它看起来尽可能专业。
当前的想法:如果有一些 AVPlayer 的示例代码,我似乎可以使用 AVVideoComposition 在视频之间切换?但目前似乎还没有关于如何发生这种情况的详细信息。
可能的线索:我认为这很容易,因为我购买了一款名为 Live Cams HD 的应用程序,它可以同时显示 16 个不同的视频源。
有什么想法吗?提前致谢!
I have to figure out the best way to transition from one video to the next
BASIC IDEA: An example would be that there is a video of a person walking.....the user taps the video and a seamless transition occurs to a video of a person running (over simplified example)
My first thought was to create 2 movie players and use transitions between the 2 view elements. But movie-player doesn't support that.
stopping the current video, loading new content, and then starting it is a solution but not very elegant. We are making a interactive sales tool for our reps and we want this to look as professional as possible.
CURRENT THOUGHT: If there was some sample code for AVPlayer, it would seem I could use AVVideoComposition to switch between videos? But details on how that might happen don't seem to be currently available.
POSSIBLE CLUE: I figured this would be easy as I bought an app called Live Cams HD that shows 16 different video feeds at once.
Any ideas? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Steve,简短的回答是,您将无法使用 AVPlayer 获得您想要的结果。 iOS 中包含的 h.264 视频逻辑非常适合同时播放视频和视频/音频,但在开始/停止以及从一个剪辑切换到另一个剪辑时确实很糟糕。原因是硬件中加载并开始播放 h.264 视频需要进行大量缓冲。基本上,您需要编写自己的代码,为您的视图设置 UIImage/CGImageRef,只需从一个 UIImage 对象数组切换到另一个数组,就可以轻松地从一个剪辑切换到另一个剪辑。当然,说起来容易,实施起来却并不那么容易。
我建议您评估已经实现此逻辑的现有代码,而不是自行编写。例如,看看这个 StreetFighter 演示应用程序。它展示了如何使用一系列剪辑来构建像 iPhone UI 这样的非常简单的游戏,这些剪辑显示角色踢腿、出拳或投掷火球。结果如下所示:
我还写了一篇关于 seamless-video-looping-on-ios。您当然可以编写自己的代码来完成所有这些操作,但我建议您在链接网站上阅读有关我的库的更多信息,因为这会节省您大量时间。
Steve, the short answer is that you are not going to be able to get the kind of results you want using AVPlayer. The h.264 video logic included in iOS is really great at playing video and video/audio together, but it really sucks at starting/stopping and switching from one clip to another. The reason is that there is a lot of buffering that needs to happen to load up and start playing a h.264 video in hardware. Basically, you need to roll your own code that sets UIImage/CGImageRef for your views in a way that makes it easy to switch from one clip to another by simply switching from one array of UIImage objects to another. Of course, that is easy to say yet not so easy to implement.
What I would suggest is that you evaluate existing code that already implements this logic instead of rolling your own. For example, have a look at this StreetFighter demo app. It shows how a very simple game like iPhone UI can be constructed using a series of clips that show a character doing a kick, a punch, or throwing a fireball. The results looks like this:
I also wrote up a blog post about seamless-video-looping-on-ios. You can of course roll your own code to do all this, but I would suggest reading more about my library at the linked website as it will save you a lot of time.
第一个视频播放完除最后一帧之外的每一帧后,您可以快速切换到包含最后一帧(基本上是最后一帧)图像的视图,然后转换到包含下一帧第一帧图像的视图视频并启动该视频。
或者,您可以使用所有帧创建一个动画(对视频进行编程),这将使其可自定义,但质量可能不会那么好,并且 CPU 使用率可能会飙升,因此您必须对该动画进行调用。
After the first video has played every frame except the last one, you quickly swap to a view with an image of the last frame (basically the last frame) and then you transition into a view with the an image of the first frame of the next video and start up that one.
Or you could create a animation with all your frames (programming your videos), that will make it customizable, but the quality will probably not be as good and the cpu usage can spike, so you will have to make a call on that one.