1
목표 -c에서 NSTask에서 ffmpeg를 호출하려고합니다. 터미널에서 ffmpeg 명령을 실행하면 매번 완벽하게 작동합니다. 나는 NSTask를 사용하여 같은 명령을 내린다. 그것은 매번 겉으로보기에 무작위의 지점에서, 출력을 통하여 반 길을 자른다. 여기 내 코드가있다.NSTask 및 FFMpeg 출력 손실
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString* ffmpegPath = [[NSBundle mainBundle] pathForResource:@"ffmpeg" ofType:@""];
NSString* path = @"test.mov";
NSTask *task = [[NSTask alloc] init];
NSArray *arguments = [NSArray arrayWithObjects: @"-i", path, nil];
NSPipe *pipe = [NSPipe pipe];
NSFileHandle * read = [pipe fileHandleForReading];
[task setLaunchPath: ffmpegPath];
[task setArguments: arguments];
[task setStandardOutput: pipe];
[task launch];
[task waitUntilExit];
NSData* data = [read readDataToEndOfFile];
NSString* stringOutput = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", stringOutput);
NSLog(@"%i", [task terminationStatus]);
NSLog(@"DONE");
}
자원 번들에 저장 한 "ffmpeg"는 무엇입니까? libavcodec.a 등의 라이브러리 (.a) 만 찾을 수 있습니다. – Swati
컴파일 된 ffmpeg 응용 프로그램 http://www.ffmpeg.org / – Morgan