iphone- [AVAssetReaderAudioMixOutput copyNextSampleBuffer] Error
I am working with AVAssetReader and AVAsse开发者_开发知识库tWriter to make movie with multi tracks. So I finished it using [AVAssetReaderAudioMixOutput copyNextSampleBuffer] and [AVAssetWriterInput appendSampleBuffer].
But I kept getting the error: [AVAssetReaderTrackOutput copyNextSampleBuffer] cannot copy next sample buffer unless the asset reader is in the 'reading' state'. How solve this problem.
MPMediaQuery *meidaQuery = [[[MPMediaQuery alloc] init] autorelease];
MPMediaItem *mediaItem = [[meidaQuery items] objectAtIndex:0];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:[mediaItem valueForProperty:MPMediaItemPropertyAssetURL] options:nil];
AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:urlAsset error:nil];
AVAssetTrack *assetTrack = [[urlAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
AVAssetReaderTrackOutput *assetReaderTrackOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:assetTrack outputSettings:NULL];
[assetReader addOutput:assetReaderTrackOutput];
[assetReader startReading];
CMSampleBufferRef sampleBufferRef = [assetReaderTrackOutput copyNextSampleBuffer];
精彩评论