我试着录一段视频,我得到的错误就像
不能记录到URL <#file url>,因为它不是文件URL。
我将目标url定义如下:
NSString *Path = [[NSString alloc] init];
Path = @"/Users/me/Documents/My fols/recording_try/newMovie.mov";
NSURL *dest = [[NSURL alloc] initWithString:[Path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];然后在创建会话之后,输入和输出对象。我试过像这样录音。
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init] ;
[mSession addOutput:mMovieFileOutput];
[mMovieFileOutput startRecordingToOutputFileURL:dest recordingDelegate:self];我已经开始运行会话,尝试使用begin和comitconfiguration,等等。但是每次运行时,我都会得到一个错误,例如:
[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - Cannot record to URL /Users/me/Documents/My%20fols/recording_try/newMovie.mov because it is not a file URL.我不知道我哪里出了问题..。有人能帮忙吗?
提前谢谢..。
发布于 2015-06-29 07:04:42
只需将NSURL配置更改为符合文件URL类型
就像这样:
NSURL *dest = [NSURL alloc initFileURLWithPath:<#(NSString *)#>]
发布于 2012-06-05 10:15:36
试着做这样的事情:
// 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] );
}https://stackoverflow.com/questions/10895294
复制相似问题