I'm new to Objective-C
. Currently I'm trying to execute lame with NSTask
. The following code seems to be working because Xcode's
output space shows me lame's standardoutput i.e. shows same as lame's output on Terminal.
But I can't get any output file i.e. test.mp3 on my desktop. Why I can't get any output? Is there any wrong with my code?
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/local/bin/lame"];
[task setArguments:[NSArray arrayWithObjects:@"/Users/xanadu62/Music/test.wav",nil]];
[task setStandardOutput:[NSFileHandle fileHandleForWritingAtPath:@"/Users/xanadu62/Desktop/test.mp3"]];
[task launch];
Also, I'd like to use "--preset extreme" as lame option. But "task setArguments
:" doesn't allow to use this option as argument. I'd like to know how can I solve this issue too.
Try it this way:
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/local/bin/lame"];
[task setArguments: [NSArray arrayWithObjects:
@"--preset",
@"extreme",
@"/Users/xanadu62/Music/test.wav",
@"/Users/xanadu62/Desktop/test.mp3",
nil]
];
[task launch];
You don't need to use pipes.
usage: lame [options] <infile> [outfile]
<infile> and/or <outfile> can be "-", which means stdin/stdout.