我想在iOS设备上以慢动作播放一段视频。
我的视图包含一个视频(大约2秒长)和一个滑块。
用户可以逐帧移动滑块并在电影中移动(前进和后退)。
MPMoviePlayerController缺乏逐帧逐帧执行的能力。
我读过关于MVAssetReader的文章,但我不知道如何使用它。
我没有固定的帧率,所以它应该把这个信息从视频的元数据中去掉。我真的需要展示每一帧画面。
有人能给我点提示吗?
发布于 2012-05-26 22:49:08
AV播放器演示WWDC 2010示例代码示例代码对您的任务很有帮助
WWDC 2010 AV Editing with AV Foundation Framework以及使用示例代码编辑音频和视频的许多其他内容中介绍了从视频中剪切缩略图
如果你有开发者账号(付费),你就可以在iTunes上观看视频
发布于 2013-06-27 06:02:05
AVFoundation是一个非常强大的框架,但是使用起来比MPMoviePlayerController需要更多的类型和理解。我强烈推荐Dinesh观看WWDC视频、查看示例代码并阅读文档。文档对于概念上的理解是很好的,但是当涉及到实际视频格式的细节时,它缺乏一些细节。因此,示例代码和实验是很好的。
如果你想一帧一帧地去做,那么我认为AVPlayerItem stepByCount:是个不错的选择。
// Setup a PlayerItem and a Player
NSURL* movieURL = [NSBundle URLForResource:@"movie" withExtension:@"mov" subdirectory:@"" inBundleWithURL:[NSBundle mainBundle].bundleURL];
AVURLAsset* movieAsset = [AVURLAsset assetWithURL:movieURL];
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
AVPlayer* player = [AVPlayer playerWithPlayerItem:playerItem];
// setup the layer so you can see it
AVPlayerLayer* playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:playerLayer];
// Verify our assumptions, in production code you should do something better
NSAsset(player.currentItem.canStepForward, @"Assume this format can step forward");
NSAsset(player.currentItem.canStepBackward, @"Assume this format can step backward");
[player.currentItem stepByCount:1]; // step forward a frame
[player.currentItem stepByCount:-1]; // step backward a framehttps://stackoverflow.com/questions/10718515
复制相似问题