Create thumbnail from a video url in IPhone SDK

Related searches

I am trying to acquire a thumbnail from a video url. The video is a stream (HLS) with the m3u8 format. I've already tried requestThumbnailImagesAtTimes from the MPMoviePlayerController, but that didn't work. Does anyone have a solution for that problem? If so how'd you do it?

If you don't want to use MPMoviePlayerController, you can do this:

    AVAsset *asset = [AVAsset assetWithURL:sourceURL];
    AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
    CMTime time = CMTimeMake(1, 1);
    CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
    UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);  // CGImageRef won't be released by ARC

Here's an example in Swift:

func thumbnail(sourceURL sourceURL:NSURL) -> UIImage {
    let asset = AVAsset(URL: sourceURL)
    let imageGenerator = AVAssetImageGenerator(asset: asset)
    let time = CMTime(seconds: 1, preferredTimescale: 1)

    do {
        let imageRef = try imageGenerator.copyCGImageAtTime(time, actualTime: nil)
        return UIImage(CGImage: imageRef)
    } catch {
        print(error)
        return UIImage(named: "some generic thumbnail")!
    }
}

I prefer using AVAssetImageGenerator over MPMoviePlayerController because it is thread-safe, and you can have more than one instantiated at a time.

How to get thumbnail image from video URL in background swift, Generate thumbnail image from video URL ios swift. Generate thumbnail image from video URL in background queue. Get image from video� The usage is very straightforward: var thumbnailImage = ROThumbnail.getThumbnail(url) It has internally three different implementations and depending on the file extension it does create the thumbnail. You can easily add your own implementation if you need a thumbnail creator for another file extension.

Acquire a thumbnail from a video url.

    NSString *strVideoURL = @"http://www.xyzvideourl.com/samplevideourl";
    NSURL *videoURL = [NSURL URLWithString:strVideoURL] ;
    MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL:videoURL]autorelease];
    UIImage  *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];
    player = nil;

Replace your video URL string with strVideoURL. You will get thumbnail as a output from video. And thumbnail is UIImage type data !

Generating Video Thumbnails at Runtime in iOS (Swift), In general, including an image url to use as a thumbnail in your api call's payload Code for getting a thumbnail from a video url in iOS Swift. Now we generate a CMTime to define where in the video we want to generate a� Create a layout like the following with a UIView and a UIButton. The UIView will be the container in which we will play our video. Add a video to the project. If you need a sample video to practice with, you can get one from sample-videos.com. I'm using an mp4 format video in this example. Drag and drop the video file into your project.

-(UIImage *)loadThumbNail:(NSURL *)urlVideo
{    
    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:urlVideo options:nil];
    AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    generate.appliesPreferredTrackTransform=TRUE;
    NSError *err = NULL;
    CMTime time = CMTimeMake(1, 60);
    CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
    NSLog(@"err==%@, imageRef==%@", err, imgRef);
    return [[UIImage alloc] initWithCGImage:imgRef];
}

Add AVFoundation framework in your project and don't forget to import <AVFoundation/AVFoundation.h> and you have to pass the path of your video saved in document directory as a parameter and receive the image as UIImage.

Getting a thumbnail from a video url or data in iOS, generate thumbnail from video ios get thumbnail from youtube video url swift Generating Video Thumbnails at Runtime in iOS (Swift), Code for getting a thumbnail Just plug a Playback ID into the Image URL API and get your first image. Bytescout Image To Video SDK. Image to video slideshow conversion - .NET & ActiveX SDK. Create slideshow with 2D and 3D effects from JPG, PNG, BMP images, with MP3, WAV sound and WMV, AVI video as output. Works in Visual C#, Visual Basic, ASP.NET, ASP classic, VB6, VBScript.

you can get the thumbnail from your video url with the use of below code

MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL:videoURL]autorelease];
UIImage  *thumbnail = [player thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

Creating video thumbnails using the iOS SDK, The iOS SDK makes it really simple to create the thumbnail images through the AVAssetImageGenerator uses the default enabled video track(s) to AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:url options:nil];� Create thumbnail from a video url in IPhone SDK Tags ajax android angular api button c++ class database date dynamic exception file function html http image input java javascript jquery json laravel list mysql object oop ph php phplaravel phpmysql phpphp post python sed select spring sql string text time url view windows wordpress xml

Maybe this is useful for someone else who faces the same problem. I needed an easy solution for creating a thumbnail for Images, PDFs and Videos. To solve that problem I've created the following Library (in Swift).

https://github.com/prine/ROThumbnailGenerator

The usage is very straightforward: var thumbnailImage = ROThumbnail.getThumbnail(url)

It has internally three different implementations and depending on the file extension it does create the thumbnail. You can easily add your own implementation if you need a thumbnail creator for another file extension.

Get Thumbail / Preview image from Server Video Url in Swift 3.0, getThumbnailFrom(path: URL(string: self.model[indexPath.row].cameraImage)!) Here is the m3u8 video url : http://dev.stream.polsecled.com:1935/polsec-� Obtention d'une vignette à partir d'une url vidéo ou de données dans le SDK iPhone j'essaie d'acquérir une vignette (de la première image) à partir d'une vidéo prise sur iphone 3GS caméra afin que je puisse l'afficher.

Step 1 - Adding video to website gallery . Copy and paste a direct link to your YouTube video (or Google Video, Metacafe, Vimeo, MySpace) into the 'Video url' field and press "Add video" button.This video Embedding Matcafe Videos will be automatically added to your website gallery.

Batch Create Image Thumbnails. Batch Create Image Thumbnails is a program that can generate all the pictures thumbnails under the directory. It provides thumbnail support two kinds of naming: the current directory of the original file name plus the prefix / custom path to maintain the original file name.

Whether you want Elastic Transcoder to create thumbnails for your videos and, if so, how you want Elastic Transcoder to name the files. If you don't want Elastic Transcoder to create thumbnails, specify "". If you do want Elastic Transcoder to create thumbnails, specify the information that you want to include in the file name for each thumbnail.

Comments
  • You can visit to the link given below. Very useful. developer.apple.com/library/IOs/#documentation/AVFoundation/…
  • Check it for once stackoverflow.com/a/45164607/3908884
  • The CGImageRef you get from -copyCGImageAtTime:actualTime:error: needs to be released with CGImageRelease();
  • Gives me the error AVErrorOperationNotSupportedForAsset . plz help
  • just as a side note... AV needs the AVFoundationFramework and CMTime needs CoreMediaFramework (had a little headache with this ones) cheers!
  • Good method but it can miss video orientation like in my case.
  • perfect...this is a good alternative for iOS 7 as thumbnailImageAtTime is now deprecated.
  • i am using this code for the thumbnail of video from the url of youtube but it is not giving me the image.i am using to put the thumbnail in the table view so can you help me
  • I think you can't get the video from Youtube URL like this www.youtube.com/watch?v=xxxxxxx
  • I'm using this url sciencentral.com/news/image_db/2024515/… I get nil thumbnail image. please help