Re: usage of afconvert with NSTask
Re: usage of afconvert with NSTask
- Subject: Re: usage of afconvert with NSTask
- From: Doug Wyatt <email@hidden>
- Date: Thu, 14 Oct 2010 08:46:42 -0700
Hi,
You don't need to do anything with pipes for standard output or standard error; afconvert does not produce an audio file on either of those streams.
I don't know why you'd get the "missing argument to -d" message unless you weren't building the argument list correctly.
"Couldn't infer file format" means that the output filename doesn't have a recognizable extension like ".aif" etc. You can be explicit and force the use of a specific filetype with the -f option.
"Couldn't open input file" may mean that you're passing a relative path where a full path is needed. The -43 error definitely means "file not found."
Doug
On Oct 14, 2010, at 3:02 , email@hidden wrote:
> Hi,
>
> I want to use the afconvert utility to convert files to aifc inside of my application using NSTask.
> In the terminal it works with :
> afconvert /Users/book/Desktop/test.wav -d BEI24 /Users/book/Desktop/test.aifc
>
> In Xcode I have a problem with the arguments, I get messages like:
> " missing argument to '-d' option"
> "Couldn't infer file format from data format 1 ch, 0 Hz, 'lpcm' (0x0000000E) 24-bit big-endian signed integer"
> "Error: Couldn't open input file (-43)"
>
> Can anybody please tell me how to set up the arguments correctly ?
> Or does somebody have a working example ?
>
> Thank you
>
> Karsten
>
>
> -(void) aifcgenerator
>
> {
> PathName = [paths objectAtIndex:0]; // Pathname and path are global
>
> NSTask *aifctask = [[[NSTask alloc] init] autorelease];
>
> [aifctask setStandardOutput: [NSPipe pipe]];
> [aifctask setStandardError: [aifctask standardOutput]];
> [aifctask setLaunchPath:@"/usr/bin/afconvert"];
> [aifctask setArguments:
> [NSArray arrayWithObjects:
> @"-d",
> @"BEI24",
> @"F32@44100",
> PathName,
> nil
> ]
> ];
> [aifctask launch];
> NSData *data =[[NSData alloc] init];
> data = [[[aifctask standardOutput] fileHandleForReading] availableData];
> [data writeToFile:derPfad atomically:NO];
>
> [aifctask terminate];
> [aifctask release];
> }
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden