我正在尝试编写一段能够“现代化”视频文件的代码。这是代码:
NSOpenPanel *openPanel = [[NSOpenPanel alloc] init];
[openPanel setCanChooseFiles:NO];
[openPanel setCanChooseDirectories:YES];
if([openPanel runModal] == NSCancelButton)
return;
NSMutableString *destination = [[[openPanel URL] absoluteString] mutableCopy];
[destination appendString:@"/"];
[destination appendString:[self fileName:[url absoluteString] withExtention:NO]];
[destination appendString:@".m4v"];
QTMovieModernizer *modernizer = [[QTMovieModernizer alloc] initWithSourceURL:url destinationURL:[NSURL URLWithString:destination]];
[modernizer modernizeWithCompletionHandler:^{NSLog(@"Modernization complete to file %@ - error : %@",[modernizer destinationURL],[modernizer error]);}];
问题是我得到NSInvalidArgumentException
。我仔细检查了源和目标网址,它们似乎没问题。错误似乎发生在QTMovieModernizer
实例的初始化。这里可能出现什么问题?
错误详情:
NSInvalidArgumentException
(
0 CoreFoundation 0x00007fff82cdc25c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff84c8ae75 objc_exception_throw + 43
2 QTKit 0x00007fff84fc4303 -[QTMovieModernizer createUniqueLegacyFilePath:extension:inDirectory:] + 0
3 MediaPlayer 0x0000000100003bb9 -[AppDelegate modernize:] + 1097
4 MediaPlayer 0x000000010000536f -[AppDelegate openFile:] + 879
5 AppKit 0x00007fff8339d340 -[NSApplication sendAction:to:from:] + 327
6 AppKit 0x00007fff833b82a8 -[NSMenuItem _corePerformAction] + 394
7 AppKit 0x00007fff833b7fe4 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 117
8 AppKit 0x00007fff8340748d -[NSMenu _internalPerformActionForItemAtIndex:] + 35
9 AppKit 0x00007fff83407309 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 104
10 AppKit 0x00007fff833ae0d6 NSSLMMenuEventHandler + 716
11 HIToolbox 0x00007fff8b7d21d4 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 892
12 HIToolbox 0x00007fff8b7d1787 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 385
13 HIToolbox 0x00007fff8b7e5880 SendEventToEventTarget + 40
14 HIToolbox 0x00007fff8b81b640 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 420
15 HIToolbox 0x00007fff8b84e238 SendMenuCommandWithContextAndModifiers + 59
16 HIToolbox 0x00007fff8b84e1e0 SendMenuItemSelectedEvent + 178
17 HIToolbox 0x00007fff8b84e0bf _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 94
18 HIToolbox 0x00007fff8b856095 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 718
19 HIToolbox 0x00007fff8b855cc1 _HandleMenuSelection2 + 446
20 AppKit 0x00007fff8332073c _NSHandleCarbonMenuEvent + 284
21 AppKit 0x00007fff8317f6be _DPSNextEvent + 2170
22 AppKit 0x00007fff8317ea2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
23 AppKit 0x00007fff83172b2c -[NSApplication run] + 553
24 AppKit 0x00007fff8315d913 NSApplicationMain + 940
25 MediaPlayer 0x0000000100008362 main + 34
26 libdyld.dylib 0x00007fff830d95fd start + 1
27 ??? 0x0000000000000003 0x0 + 3
)
编辑:
我发现-fileName:withExtension:
通过用空格替换%20
来返回一个字符串。处理完之后,initsilizing的异常消失了,但转换文件时出现以下错误:
<<<< QTMovieModernizer >>>> FigFormatUtilsCreateFormatReader: Error -12848 from FigFormatReaderCreateForStream
<<<< QTMovieModernizer >>>> formatReaderForSourceURL: Error in FormatReaderForSourceURL: -12848