Home > Software engineering >  Swift - generating image thumbnail from a local video
Swift - generating image thumbnail from a local video

Time:07-31

I'm trying to create a Thumbnail image from a video:

    func getImageFromUrl(url:URL) -> UIImage?{
    print(url)
    let video = AVURLAsset(url: url)
        let thumbnailGenerator = AVAssetImageGenerator(asset: video)

        do
        {
            let cgImage = try thumbnailGenerator.copyCGImage(at: CMTimeMake(value: 0, timescale: 1), actualTime: nil)
            let UiImage = UIImage(cgImage: cgImage)
            return UiImage
        }
        catch
        { print(error) }
    return nil
}

and I'm getting this Error:

Error Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation Stopped, NSUnderlyingError=0x2804c50b0 {Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"}}

HELP ANYONE ?

CodePudding user response:

That error tells us that this is an HTTP, not local issue. The Apple Developer Documentation says "This error might indicate that the HTTP server doesn’t support byte range requests." and or that "The HTTP server sending the media resource is not configured as expected." Check to make sure the HTTP server is configured properly and allows this type of query.

CodePudding user response:

It looks like a server issue as peer apple documentation

case serverIncorrectlyConfigured = -11850

This error might indicate that the server doesn’t support byte-range requests.

You can try this video URL to check if your code actually works:

https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4

Will you be able to share the video URL to check?

  • Related