我正在尝试使用AVFoundation(AVCaptureOutput + AVAssetWriter)录制视频,同时从iPod库而不是麦克风播放音频。我使用了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等应用程序如何实现的建议?