开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜