Reputation: 199
I have to extract all frames from video file and then save them to file.
I tried to use AVAssetImageGenerator
, but it's very slow - it takes 1s - 3s per each frame ( sample 1280x720 MPEG4 video ) without saving to file process.
Is there anyway to make it much faster? OpenGL, GPU, (...)?
I will be very grateful for showing me right direction.
Upvotes: 3
Views: 1166
Reputation: 36072
AVAssetImageGenerator
is a random access (seeking) interface, and seeking takes time, so one optimisation could be to use an AVAssetReader
which will quickly and sequentially vend you frames. You can also choose to work in yuv format, which will give you smaller frames (and I think) faster decoding.
However, those raw frames are enormous: are 1280px * 720px * 4 bytes/pixel (if in RGBA), which is about 3.6MB each. You're going to need some pretty serious compression if you want to keep them all (MPEG4 @ 720p comes to mind :).
So what are you trying to achieve?
Are you sure you want fill up your users' disks at a rate of 108MB/s (at 30fps) or 864MB/s (at 240fps)?
Upvotes: 3