iosiphoneavfoundationavassetavassetreader

Get a particular frame by time value using 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.

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

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


Solution

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

    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.

    Two things you need to keep in mind:

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

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

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