Getting a thumbnail of a *.mov video IOS
Here it is... (Picked up from this link- Getting video snapshot for thumbnail)
- (UIImage *)thumbnailImageFromURL:(NSURL *)videoURL {
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL: videoURL options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
NSError *err = NULL;
CMTime requestedTime = CMTimeMake(1, 60); // To create thumbnail image
CGImageRef imgRef = [generator copyCGImageAtTime:requestedTime actualTime:NULL error:&err];
NSLog(@"err = %@, imageRef = %@", err, imgRef);
UIImage *thumbnailImage = [[UIImage alloc] initWithCGImage:imgRef];
CGImageRelease(imgRef); // MUST release explicitly to avoid memory leak
return thumbnailImage;
}
Getting video snapshot for thumbnail
To fix the thumbnail orientation set appliesPreferredTrackTransform
to YES
in the AVAssetImageGenerator
instance. If you add your own video composition, you'll need to include the right transform to rotate the video as wanted.
generate.appliesPreferredTrackTransform = YES;
Remember to release the obtained image reference with CGImageRelease
.
To request multiple thumbnails it's better to do asynchronously with generateCGImagesAsynchronouslyForTimes:completionHandler:
.
iOS how to insert an inline photo or video thumbnail in a UITextView?
On iOS 7 or later, you can use NSTextAttachment to insert an inline image to UITextView. See this for an example: https://stackoverflow.com/a/20930656/1262685
For the video thumbnail, you'll need to create the thumbnail yourself. Here's one way to do it: https://stackoverflow.com/a/19530997/1262685
How can I fix these compilation errors?
The compiler is telling you, that you cannot use the List.Add()
method that expects a string
as input, because you're handing it the return of Split()
which returns a string[]
. To use a string[]
as input, use AddRange()
.
Related Topics
What Is the Impact of the "Requires Full Screen" Option in Xcode for an Iphone-Only App
Sqlite Database on Phonegap/iOS - More Than 5Mb Possible
Annotation Along Route in Mapkit
Not Receiving Any Push Notification in Iphone
How to Draw a Non-Rectangle Uitextview
Importing Swift Framework into a Objective-C Project
Converting Uiimageview Touch Coordinates to Uiimage Coordinates
Marker Click Event on React Native Maps Not Working in React iOS
Fcm Notification in iOS Doesn't Play Sound When Received
Import Framework in Swift Project, Xcode
Skspritenode Position in Universal Game
Dragging Scnnode in Arkit Using Scenekit
Find Size Contributed by Each External Library on iOS
How to Delete a Child from Firebase (Swift)
"This App Is Not Allowed to Query for Scheme Cydia" iOS9 Error