gpt4 book ai didi

objective-c - NSTask 失败 22 终止临时进程 cocoa

转载 作者:行者123 更新时间:2023-12-03 17:14:57 26 4
gpt4 key购买 nike

使用下面的代码,我收到此错误:

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

我不明白这背后的问题是什么。

- (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 的值为:

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

NSLOG 中的值:

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

请帮助解决此问题。

最佳答案

您没有提供正确的文件来执行;你正在经过它的路径(大概)。

您可能需要类似的东西:

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

注意:比 error 22 清楚是 errnoEINVAL,但是 exec() 上没有对它的引用 manpageexecve() manpage .,所以我不知道您如何仅根据错误代码来确定原因。

关于objective-c - NSTask 失败 22 终止临时进程 cocoa ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9567442/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com