skip to Main Content

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 ?

3

Answers


  1. 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.

    Login or Signup to reply.
  2. 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?

    Login or Signup to reply.
  3. Also, copyCGImage is Deprecated

    Try using image(at:) instead.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search