1. 在iOS上开发视频操作的时候,出现错误:
Error Domain=AVFoundationErrorDomain Code=-11800 "这项操作无法完成"UserInfo=0x1780fb480 {NSUnderlyingError=0x1706495d0 "The operation couldn’t be completed. (OSStatus error -12673.)", NSLocalizedFailureReason=发生未知错误(-12673), AVErrorRecordingSuccessfullyFinishedKey=false, NSLocalizedDescription=这项操作无法完成},file:///var/mobile/Applications/D0CA65C7-F218-46F1-80BC-B0FA886EDF3B/video.mov
具体是使用AVFoundation录制使用,然后保存再文件中。
产生错误:Error Domain=AVFoundationErrorDomain Code=-11800 "这项操作无法完成"的原因都是因为存储的文件路径NSURL有问题。即使你打印出来没有什么问题,但是就是报错,确实蛋疼。
解决办法,重写输出文件的路径NSURL。给一个例子:
//初始化保存的路径
1
2
3
|
NSString *documentsDirPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSURL *documentsDirUrl = [NSURL fileURLWithPath:documentsDirPath isDirectory:YES];
self.saveMovieFile = [NSURL URLWithString:@
"video.mp4"
relativeToURL:documentsDirUrl];
|
当然,在使用这个路径之前,记得先检查这个文件是否存在,如果存在则先删除文件,否则会报另外一个错误。
转自:http://www.faceye.net/search/129895.html
2. appendPixelBuffer fail
打印错误的方法:
NSError *error = [assetWriter error];
NSLog(@"buffer append fail! error:%@", [errordescription]);
未知错误:buffer append fail! error:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x7b3a0210 {Error Domain=NSOSStatusErrorDomain Code=-16364 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16364)}
这个错误是由于append buffer前后的时间差必须大于等于所设置的1/timescle(或者大于1.0/600?),不知道是不是由于timescale引起的,反正判断了一下前后两帧的时间差如果小于1.0/timescale这一帧我就丢掉了,结果没有错误发生,合成完成!