本文介绍了使用AVAssetReader按时间值获取特定帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查了此 http://www. 7twenty7.com/blog/2010/11/video-processing-with-av-foundation 逐帧获取视频.但是我真正的要求是在特定时间获得框架.我知道AVAssetReader应该有可能,我想知道AVAssetReader中是否有任何直接方法可以做到这一点.请提供有关如何在特定时间获得帧的任何指导.

I have checked this http://www.7twenty7.com/blog/2010/11/video-processing-with-av-foundation to get a video frame by frame. But my real requirement is to get a frame at particular time. I know that it should be possible by AVAssetReader, I wonder is there any direct method for this in AVAssetReader. Please give any guidance on how can I get frame at particular time.

我检查了AVAssetImageGenerator,但这不是我真正想要的.

I checked the AVAssetImageGenerator but this is not the thing I really wanted.

最后我找到了答案,您必须使用timeRange属性.那是唯一的方法.

Finally I found the answer, you have to use timeRange property. Thats the only way for this.

推荐答案

最后,我得到了答案.我在这里发布我的解决方案,希望对您有所帮助.

Finally I got an answer for this. I am posting my solution here, hope it helps some one.

使用AVAssetReader timeRange属性选择任何时间范围内的帧.如果要查找特定的帧,只需提供相同的开始时间和结束时间即可.

Use AVAssetReader timeRange property for selecting frames in any time range.If you are looking for particular frame just provide start and end time as same.

您需要记住两件事:

1.一旦调用AVAssetReader startReading方法,就无法重置timeRange.

1.once you call AVAssetReader startReading method you cannot reset timeRange.

2.您必须为此重新创建AVAssetReader,使用stopReading方法也确实无济于事.

2.You have to recreate AVAssetReader for this, using stopReading method also really won't help.

此链接可能也非常有用,我发现所有这些都非常有帮助:)如何使用avassetreader在音轨中进行搜索?

This link might be also really useful, I found all these very helpful:)How to seek within an audio track using avassetreader?

这篇关于使用AVAssetReader按时间值获取特定帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-23 15:23