UISaveVideoAtPathToSavedPhotosAlbum 崩溃

发布于 2025-01-03 15:17:07 字数 1194 浏览 5 评论 0原文

我有一个处于视频模式的 UIImagePickerController;完成录制视频并点击“使用”按钮接受视频后,我使用此方法 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 在其中我想将视频保存在相机胶卷中并从视频中检索第一帧以在 UIImageView 中显示它。我使用的代码如下:

    NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
    NSURL *url = [NSURL fileURLWithPath:tempFilePath];
            
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    moviePlayer.shouldAutoplay = NO;
    imageView.image = [moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

问题是,如果我添加方法 UISaveVideoAtPathToSavedPhotosAlbum 应用程序崩溃。

UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self,  @selector(video:didFinishSavingWithError:contextInfo:), nil);

其中 tmpFilePath 与我上面使用的相同。

相反,如果我仅使用此操作之一(UISaveVideoAtPathToSavedPhotosAlbum 或检索帧),则一切正常!

控制台报这个错误:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“+[NSInitation invocateWithMethodSignature:]:方法签名参数不能为 nil”

有什么想法吗?谢谢...

I've a UIImagePickerController in video mode; after I finish recording video and I tap on "Use" button to accept the video I use this method -(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
and inside it i want save the video in camera roll and retrieve the first frame from the video to show it in UIImageView. The code that I use is the following:

    NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
    NSURL *url = [NSURL fileURLWithPath:tempFilePath];
            
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
    moviePlayer.shouldAutoplay = NO;
    imageView.image = [moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

The problem is that if I add the method UISaveVideoAtPathToSavedPhotosAlbum the app crash.

UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self,  @selector(video:didFinishSavingWithError:contextInfo:), nil);

where tmpFilePath is the same that I used above.

Instead if I use only one of this operation (UISaveVideoAtPathToSavedPhotosAlbum or retrieve frame) all work fine !

The console report this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil'

Any ideas ? Thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

维持三分热 2025-01-10 15:17:07

在你的课堂上,你是否实现了以下方法?

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {

In your class, do you implement the following method?

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文