An AVAssetImageGenerator object provides thumbnail or preview images of assets independently of playback.
Questions tagged [avassetimagegenerator]
51 questions
17
votes
3 answers
m3u8 file AVAssetImageGenerator error
I am using AVPlayer to play .m3u8 file.
Using AVAssetImageGenerator to extract image out of it using following code :
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:mp.contentURL options:nil];
AVAssetImageGenerator *generate1 =…

objectivecdeveloper
- 1,050
- 11
- 29
14
votes
2 answers
generateCGImagesAsynchronouslyForTimes sometimes don't generate entire thumbnails
I'm working on an OS X app that is using AVAssetImageGenerator.generateCGImagesAsynchronouslyForTimes, and it normally works fine. However, once in a while the thumbnail I get back only contains the first few rows of pixels, and the rest is green,…

Addison
- 3,791
- 3
- 28
- 48
10
votes
1 answer
How do I know when generateCGImagesAsynchronously has completely finished?
I have a requirement to take a video, convert each frame to and image and save these images to disk. I'd like to use AVAssetImageGenerator for efficiency's sake, and have code similar to the following:
The issue is that I don't know when all image…

terrafirma9
- 362
- 2
- 15
9
votes
4 answers
How do I implement AVAssetImageGenerator.copyCGImageAtTime in swift
Thus far I have the following
let assetUrl = NSURL.URLWithString(self.targetVideoString)
let asset: AVAsset = AVAsset.assetWithURL(assetUrl) as AVAsset
let imageGenerator = AVAssetImageGenerator(asset: asset);
let time : CMTime =…

user379468
- 3,989
- 10
- 50
- 68
8
votes
1 answer
AVAssetImageGenerator fails at copying image
I am using AVAssetImageGenerator to create an image from the last frame of a video. This usually works fine, but every now and then copyCGImageAtTime fails with the error
NSLocalizedDescription = "Cannot Open";
NSLocalizedFailureReason = "This…

Daniel Larsson
- 6,278
- 5
- 44
- 82
7
votes
2 answers
AVAssetImageGenerator performance issue
I am trying to create a video gallery.
To display videos I am using a UICollectionView. Each UICollectionViewCell has a background with video thumbnail. To generate a video thumbnail I am using a method with logic:
AVURLAsset *asset = [[AVURLAsset…

Daumantas Versockas
- 797
- 1
- 10
- 29
7
votes
4 answers
Get orientation from video or thumb obtained with AVAssetImageGenerator
In my application I create videos from single images. Everything works fine, videos are assembled correctly with right size and orientation. They are displayed correctly both in the Apple photo app, from MPMoviePlayer and from the sandbox directory…

Andrea
- 26,120
- 10
- 85
- 131
5
votes
0 answers
Extract image from video, image color is different swift
I capture video using AVCaptureSession session preset is
session!.sessionPreset = AVCaptureSessionPreset1280x720
and extract image from video using this code
func videoThumbnails(url: NSURL ){
let asset = AVAsset(URL: url)
let…

Muhammad Raza
- 952
- 7
- 24
4
votes
0 answers
generateCGImagesAsynchronously produces duplicate images according to actualTime
I am able to get the frames from a video using AVAssetImageGenerator, and I do so using generateCGImagesAsynchronously. Whenever the result succeeds, I print the requestedTime in seconds as well as the actualTime for that image. In the end, however,…

bruteforce
- 83
- 7
3
votes
1 answer
Thumbnail generation for Video fails if video originates from local Library Folder
Using iOS14.5, Swift5.4, Xcode12.5,
I try to create a thumbnail image of a video in Swift.
It all works for a video that originates from the Internet.
However, in my case, the video originates from the Library Folder of the App where it was…

iKK
- 6,394
- 10
- 58
- 131
3
votes
0 answers
Can't use image thumbnail from live stream(m3u8) in collectionView Swift 4
It's part of my code (written in Swift 4, xcode 9.2), where I want to do that.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell =…

Ruben Nahatakyan
- 372
- 3
- 13
3
votes
1 answer
How to get the start and end time for the selected frames from the video using iOS sdk?
What i am trying to do:
I am trying to get the start and end time of the frames chosen as in the attachement below:
What i have done so far:
UIImagePickerController: Implemented and found that start and end time won't be returned from the delegate…

2vision2
- 4,933
- 16
- 83
- 164
2
votes
1 answer
AVAssetImageGenerator copyCGImageAtTime:actualTime:error: generates 8-bit images from 10-bit video
I've got a 10-bit video on my Mac that I want to extract frames in full 10-bit/channel data. I load my asset, and verify that it's 10-bit:
CMFormatDescriptionRef formatDescriptions = (__bridge…

Can Poyrazoğlu
- 33,241
- 48
- 191
- 389
2
votes
1 answer
Unable to generate thumbnail from video url
I am using the this code for generating thumbnail from a video url
AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:videoUrl options:nil];
AVAssetImageGenerator *generator =
[[AVAssetImageGenerator alloc] initWithAsset:asset];
…

iYousafzai
- 1,021
- 1
- 10
- 29
2
votes
0 answers
iOS swift : generateCGImagesAsynchronouslyForTimes takes too long and freezes the app?
I'm getting video thumbnails asynchronously with the following code:
let imgGenerator = AVAssetImageGenerator(asset: asset)
imgGenerator.generateCGImagesAsynchronouslyForTimes([NSValue(CMTime: CMTimeMake(1, 30))]) {(time1, image, time2,…

Sam
- 1,101
- 2
- 13
- 26