2012-02-24 95 views
0

我想写通过AVAssetWriter创建的视频文件,它抛出以下错误:AVAssetWriter显示URL错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[AVAssetWriter initWithURL:fileType:error:] invalid parameter not satisfying: [outputURL isFileURL]'

我的代码如下:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *savedVideoPath = [documentsDirectory stringByAppendingPathComponent:@"videoOutput"]; 

NSURL *url = [NSURL URLWithString:[appDelegate_.documentDirectory 
    stringByAppendingPathComponent:@"VideoRecording.mov"]]; 
NSError *error = nil; 
videoWriter_ = [[AVAssetWriter alloc] initWithURL:url fileType:AVFileTypeQuickTimeMovie error:&error]; 

任何帮助将是明显的。提前致谢。

回答

0

1)我没有看到你用savedVideoPath字符串做任何事情,你去麻烦创建你的代码片段。

2)如果你在代码中设置断点并在调试器中查找,我猜你会看到你的appDelegate_.documentDirectory为零。

0

试图改变你的代码

NSURL *url = [NSURL -->URLWithString<---:...]

[NSURL fileURLWithPath:]

,然后再试一次。