0

I'm trying to write a piece of code that would "modernize" a video file. This is the code :

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]);}];

The problem is that I get an NSInvalidArgumentException. I've checked the source and destination url carefully and they seem to be ok. The error seems to happen at the initialization the QTMovieModernizer instance. What can be going wrong here?


Error details :

 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
   )

EDIT :

I found out that -fileName:withExtension: returns a string by replacing %20 by spaces. After handling this, the exception at the initsilizing is gone but instead, I have the following error when converting the file :

  <<<< QTMovieModernizer >>>> FigFormatUtilsCreateFormatReader: Error -12848 from       FigFormatReaderCreateForStream
  <<<< QTMovieModernizer >>>> formatReaderForSourceURL: Error in FormatReaderForSourceURL: -12848
user26830
  • 1,059
  • 4
  • 16
  • 25
  • What's the full error message? – rmaddy May 14 '14 at 17:55
  • @rmaddy that's the full error message just `An uncaught exception was raised` before this. – user26830 May 14 '14 at 18:07
  • if you can print out the full source & destination URL's, what do they look like? – Michael Dautermann May 14 '14 at 18:10
  • @MichaelDautermann the variable are here : `destination __NSCFString * @"file:///Users/Moray/Desktop//S1%20E01%20-%20My%20First%20Day.m4v" 0x0000608000a75240`, `url NSURL * @"file:///Users/Moray/Movies/Scrubs/Season%201/S1%20E01%20-%20My%20First%20Day.avi" 0x000060000067a340` – user26830 May 14 '14 at 18:15

0 Answers0