Description
It is quite painful where you have a decent video API, but doesn’t provide you with a thumbnail. This makes it very hard to demonstrate to users what the video looks like a first glance.
Therefore, we have came up with a technique that buffers the first minute of a video and generate a thumbnail on the fly.
Code
Using AVAsset
, we can write an extension that dispatches a thread dedicated to generate a thumbnail (also duration of the video in the case below).
1 | extension AVAsset { |
More
For more information, checkout
- AVAsset - AVFoundation | Apple Developer Documentation
- Generate images from AVAsset with AVAssetImageGenerator