2012-02-24 61 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:]

,然後再試一次。