I am trying to record video using AVFoundation (AVCaptureOutput + AVAssetWriter) while playing Audio from iPod library instead of the microphone. I took RosyWriter sample code and removed the AudioInput and instead setup AVAssetReader for reading the song in uncompressed format,
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:44100.0], AVSampleRateKey,
[NSNumber numberWithInt:16], AVLinearPCMBitDepthKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
[NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
[NSNumber numberWithBool:NO], AVLinearPCMIsBigEndianKey,
nil];
mAssetReader = [[AVAssetReader alloc] initWithAsset:mAsset error:nil];
mAssetReaderOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:audioTrack outputSettings:outputSettings];
if ([mAssetReader canAddOutput:mAssetReaderOutput]) {
[mAssetReader addOutput:mAssetReaderOutput];
}
[mAssetReader startReading];
and then periodically poll the audio samples. But it's not working correctly. Any advice on how apps like VideoStar or Blux Movie achieve it ?