2012-03-05 55 views
1

使用下面的代碼,我收到此錯誤:NSTask失敗22撤消臨時過程可可

NSTask: Task create for path '/Users/media/Library/Developer/Xcode/DerivedData/Manager-gnixeptcszdoubbnfcncumzypwge/Build/Products/Debug/lib' failed: 22, "Invalid argument". Terminating temporary process. 

我沒有得到什麼這背後的問題。對於ffmpegPresetLaunchPath

- (void)startProcessingVideo { 

    NSLog(@"Processing Video Low Resolution"); 

    NSTimeInterval timeStamp = [[NSDate date] timeIntervalSince1970]; 
    // NSTimeInterval is defined as double 
    NSNumber *timeStampObj = [NSNumber numberWithInt:timeStamp]; 

    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; 
    [formatter setNumberStyle:NSNumberFormatterNoStyle]; 

    NSString *convertNumber = [formatter stringForObjectValue:timeStampObj]; 

    NSLog(@"timeStampObj:: %@", convertNumber); 

    NSString *fileNameNumber = [convertNumber stringByAppendingString:[self genRandStringLength:8]]; 

    NSLog(@"fileNameNumber:::: %@", fileNameNumber); 

    NSString *aString = [[NSString stringWithFormat:@"%@%@%@", thumbnailDirPath,@"/Mobile" ,fileNameNumber] retain]; 

    //NSString *string = [aString stringByAppendingString:@"_H"]; 

    fileNameMP4Mobile = [aString stringByAppendingString:@".mp4"]; 

    NSLog(@"string:::: %@", aString); 

    [lblMessage setStringValue:@"Started!"]; 
    NSTask *task= [NSTask new]; 
    [task setLaunchPath:ffmpegPresetLaunchPath]; 
    [task setArguments:[NSArray arrayWithObjects: 
         @"-y", 
         @"-i", 
         inputFilePath,// @"1.wmv", 
         @"-vcodec", 
         @"libx264", 
         @"-fpre", 
         @"libx264-fast.ffpreset", 
         @"-b", 
         @"500k", 
         @"-s", 
         @"640*480", 
         @"-r", 
         @"30", 
         @"-aspect", 
         @"16:9", 
         @"-ab", 
         @"128k", 
         @"-ac", 
         @"2", 
         @"-ar", 
         @"44100", 
         fileNameMP4Mobile,nil]]; 
    [task setCurrentDirectoryPath:thumbnailDirPath]; 

    NSPipe *outputPipe = [NSPipe pipe]; 
    [task setStandardInput:[NSPipe pipe]]; 
    [task setStandardOutput:outputPipe]; 

    [task launch]; 
    [task waitUntilExit]; 
    [task release]; 

    NSData *outputData = [[outputPipe fileHandleForReading] readDataToEndOfFile]; 
    NSString *outputString = [[[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding] autorelease]; 
    [lblMessage setStringValue:@"Video Generated!"]; 

    [self startProcessingVideoHighResolution]; 
} 

值:

ffmpegPresetLaunchPath = [[NSString stringWithFormat:@"%@%@", currentDir, @"/lib/"] retain]; 

價值的NSLog:

ffmpegPresetLaunchPath::: /Users/media/Library/Developer/Xcode/DerivedData/FileManager-gnixeptcszdoubbnfcncumzypwge/Build/Products/Debug/lib/ 

請幫助解決這個問題。

+0

請顯示'ffmpegPresetLaunchPath'的值;這幾乎肯定會導致錯誤。 – trojanfoe 2012-03-05 13:50:20

+0

請檢查,我編輯了這個問題。 – 2012-03-05 14:00:58

回答

1

您未提供執行正確的文件;你正在通過它的路徑(大概)。

你可能需要的東西,如:

ffmpegPresetLaunchPath = [[NSString stringWithFormat:@"%@%@", currentDir, @"/lib/ffmpeg"] retain]; 

注:很明顯比error 22errno價值EINVAL,但是有它沒有提到對exec()manpageexecve()manpage,所以我不知道。知道你如何期望從錯誤代碼中確定原因。

+0

Thanx @trojanfoe,你救了我的一天哥們:) – 2012-03-05 14:27:17