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
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.
It looks like a server issue as peer apple documentation
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:
Will you be able to share the video URL to check?
Also,
copyCGImage
is DeprecatedTry using image(at:) instead.