Re: Solved: recording audio from isight
Re: Solved: recording audio from isight
- Subject: Re: Solved: recording audio from isight
- From: William Stewart <email@hidden>
- Date: Mon, 9 Jan 2006 11:04:11 -0800
AAC does not do 512 frames per packet, it does 1024 (regardless of
the sample or bit rate).
The 512 here is probably being ignored when you create the converter.
Bill
On 07/01/2006, at 2:10 PM, Olivier Destrebecq wrote:
For everyone's benefit here is the solution to the problem:
I needed to set the sample rate to the incoming sample rate of the
device:
MTCoreAudioStreamDescription *inputStreamDescription =
[recordingDevice streamDescriptionForChannel: 1
forDirection: kMTCoreAudioDeviceRecordDirection];
MTCoreAudioStreamDescription *audioStreamDescription =
[MTCoreAudioStreamDescription streamDescription];
[audioStreamDescription setFormatID: kAudioFormatMPEG4AAC];
[audioStreamDescription setChannelsPerFrame: 1];
[audioStreamDescription setFormatFlags: 2];
[audioStreamDescription setFramesPerPacket: 512]; //64kbps
[audioStreamDescription setSampleRate:
[inputStreamDescription sampleRate]];
Olivier Destrebecq
http://otusweb.spymac.com/portfolio/
On Jan 7, 2006, at 3:52 PM, Olivier Destrebecq wrote:
I'm trying to record an AAC file from an isight
I've modeled my code after the audioFileRecorder source code.
Unfortunately, when i use my code to record with an isight, i get
a zero Kb file. If i use the build in audio or an imic for input
it works just fine.
When i try to record the file using the command line tool
afrecord, it records and grows the file, but then quicktime says
it has a length of 0 seconds.
here is the code any pointers appreciated:
const unsigned kBufferSize = 0x8000;
[self setAudioFileRecorder: new
CAAudioFileRecorderInputSelection(3, kBufferSize)]; //8Kb buffer
//set the input device for the file recorder
//
[self audioFileRecorder]->setDefaultInput([recordingDevice
deviceID]);
//create the directory reference and the file reference
//
FSRef parentDir;
CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath: [[self
tempFileRecordingPath] stringByDeletingLastPathComponent]],
&parentDir);
//set the format for the destination file (AAC for our purpose)
//
MTCoreAudioStreamDescription *audioStreamDescription =
[MTCoreAudioStreamDescription streamDescription];
[audioStreamDescription setFormatID: kAudioFormatMPEG4AAC];
[audioStreamDescription setChannelsPerFrame: 1];
[audioStreamDescription setFormatFlags: 2];
[audioStreamDescription setFramesPerPacket: 512]; //64kbps
[audioStreamDescription setSampleRate: 44100];
//create the audio file for the recorder
//
[self audioFileRecorder]->SetFile(parentDir,
(CFStringRef) [[self
tempFileRecordingPath] lastPathComponent],
kAudioFileM4AType,
CAStreamBasicDescription
([audioStreamDescription audioStreamBasicDescription]),
NULL);
//turn off file caching, as recommanded on mailing lists
//
NSFileHandle* file = [[NSFileHandle fileHandleForReadingAtPath:
[self tempFileRecordingPath]] retain];
fcntl([file fileDescriptor], F_NOCACHE, 1);
//begin the recording
//
[self audioFileRecorder]->Start();
void CAAudioFileRecorderInputSelection::setDefaultInput
(AudioDeviceID inputDevice)
{
XThrowIfError(
AudioUnitSetProperty(mInputUnit,
kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0,
&inputDevice, sizeof(inputDevice)),
"failed to select input device");
}
Olivier Destrebecq
http://otusweb.spymac.com/portfolio/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40umich.edu
This email sent to email@hidden
_______________________________________________
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
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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