首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用AVCaptureMovieFileoutput录制电影

无法使用AVCaptureMovieFileoutput录制电影
EN

Stack Overflow用户
提问于 2012-06-05 10:04:14
回答 2查看 1.6K关注 0票数 1

我试着录一段视频,我得到的错误就像

不能记录到URL <#file url>,因为它不是文件URL。

我将目标url定义如下:

代码语言:javascript
复制
NSString *Path = [[NSString alloc] init];
Path = @"/Users/me/Documents/My fols/recording_try/newMovie.mov";
NSURL *dest = [[NSURL alloc] initWithString:[Path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

然后在创建会话之后,输入和输出对象。我试过像这样录音。

代码语言:javascript
复制
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init] ;
[mSession addOutput:mMovieFileOutput];
[mMovieFileOutput startRecordingToOutputFileURL:dest recordingDelegate:self];

我已经开始运行会话,尝试使用begin和comitconfiguration,等等。但是每次运行时,我都会得到一个错误,例如:

代码语言:javascript
复制
[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - Cannot record to URL /Users/me/Documents/My%20fols/recording_try/newMovie.mov because it is not a file URL.

我不知道我哪里出了问题..。有人能帮忙吗?

提前谢谢..。

EN

回答 2

Stack Overflow用户

发布于 2015-06-29 07:04:42

只需将NSURL配置更改为符合文件URL类型

就像这样:

NSURL *dest = [NSURL alloc initFileURLWithPath:<#(NSString *)#>]

票数 2
EN

Stack Overflow用户

发布于 2012-06-05 10:15:36

试着做这样的事情:

代码语言:javascript
复制
// variable names should start with lower case letters

// also, let's do as much as we can with auto-released objects
// so we don't have to worry about leaking (if we're not using ARC)
NSString *path = [NSString stringWithString: @"/Users/me/Documents/My fols/recording_try"];
NSURL *dest = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if(dest == nil)
{
    NSLog( @"does not appear to be a valid NSURL object" );
    return;
}

NSError * error = nil;
if([[NSFileManager defaultManager] createDirectoryAtURL: dest withIntermediateDirectories: YES attributes: nil error: &error] == YES)
{
    dest = [dest URLByAppendingPathComponent: @"newMovie.mov"];

    // now you can create the session plus input and output objects
    // within this block

} else {
    NSLog( @"was not able to create the directory which contains path %@ - error is %@", path, [error localizedDescription] );
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10895294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档