Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为.mov文件目标C生成视频缩略图_Ios_Objective C - Fatal编程技术网

Ios 为.mov文件目标C生成视频缩略图

Ios 为.mov文件目标C生成视频缩略图,ios,objective-c,Ios,Objective C,我正在尝试生成缩略图并将其保存到文件中。这是我的密码 AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:object[@"path"] options:nil]; AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; NSError *err = NULL; CMTime reques

我正在尝试生成缩略图并将其保存到文件中。这是我的密码

   AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:object[@"path"] 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);

     NSString* path = [NSHomeDirectory() stringByAppendingString:@"/Documents/myImage.png"];
     BOOL ok = [[NSFileManager defaultManager] createFileAtPath:path
                                                contents:nil attributes:nil];
     if (!ok)
     {
       NSLog(@"Error creating file %@", path);
     }
     else
     {
       NSFileHandle* myFileHandle = [NSFileHandle        fileHandleForWritingAtPath:path];
       [myFileHandle writeData:UIImagePNGRepresentation(thumbnailImage)];
       [myFileHandle closeFile];
       resolve(path);
     }
但我得到了一个错误:

 Code=-11822 "Cannot Open" UserInfo={NSLocalizedDescription=Cannot Open, NSLocalizedFailureReason=This media format is not supported.}

有什么想法吗

哪一行导致了错误?仅供参考-用于构建文档文件夹路径的代码错误。而且你编写文件的代码比它需要的要困难得多。不,确实是代码,它工作得很好:)。我发送到生成器的URL有问题。在哪一行抛出错误?