在iOS下逐帧阅读视频 [英] Reading video frame-by-frame under iOS

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

问题描述

我正在寻找一种使用iOS API检索视频的各个帧的方法。
我尝试使用AVAssetImageGenerator,但它似乎只提供了最接近的秒的帧,这对于我的使用来说有点过于粗糙。

I'm looking for a way to retrieve the individual frames of a video using iOS API. I tried using AVAssetImageGenerator but it seems to only provide frame to the nearest second which is a bit too rough for my usage.

据我所知文档,AVAssetReader,AVAssetReaderOutput和CMSampleBufferGetImageBuffer的管道我应该可以做一些事情,但我坚持使用CVImageBufferRef。有了这个,我正在寻找一种方法来获得CGImageRef或UIImage,但还没有找到它。

From what I understand of the documentation, a pipeline of AVAssetReader, AVAssetReaderOutput and CMSampleBufferGetImageBuffer I should be able to do something but I'm stuck with a CVImageBufferRef. With this I'm looking for a way to get a CGImageRef or a UIImage but haven't found it.

不需要实时,我可以坚持下去提供API更好。

Real-time is not needed and the more I can stick to provided API the better.

非常感谢!

编辑:
基于这个网站: http://www.7twenty7.com/blog / 2010/11 / video-processing-with-av-foundation 和这个问题:如何将CVImageBufferRef转换为UIImage 我正在接近一个解决方案。问题,AVAssetReader在第一个 copyNextSampleBuffer 之后停止读取而没有给我任何东西(sampleBuffer为NULL)。

Based on this site: http://www.7twenty7.com/blog/2010/11/video-processing-with-av-foundation and this question: how to convert a CVImageBufferRef to UIImage I'm nearing on a solution. Problem, the AVAssetReader stops reading after the first copyNextSampleBuffer without giving me anything (the sampleBuffer is NULL).

视频可由MPMoviePlayerController读取。我不明白什么是错的。

The video is readable by MPMoviePlayerController. I don't understand what's wrong.

推荐答案

上面的两个链接实际上回答了我的问题,空的 copyNextBufferSample 是iOS SDK 5.0b3的问题,它可以在设备上运行。

The two links above actually answer my question and the empty copyNextBufferSample is an issue with iOS SDK 5.0b3, it works on the device.

这篇关于在iOS下逐帧阅读视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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