マイクの代わりに iPod ライブラリからオーディオを再生しながら、AVFoundation (AVCaptureOutput + AVAssetWriter) を使用してビデオを録画しようとしています。RosyWriter のサンプル コードを使用して AudioInput を削除し、代わりに AVAssetReader を設定して非圧縮形式で曲を読み取るようにしました。
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];
次に、オーディオ サンプルを定期的にポーリングします。しかし、それは正しく機能していません。VideoStar や Blux Movie などのアプリがそれを達成する方法について何かアドバイスはありますか?