当我使用 AVAssetWriterInput 时,readyForMoreMediaData 的值始终为 NO,但为什么呢?
when i use AVAssetWriterInput, the value of readyForMoreMediaData is always is NO, but why?
当我使用AVFoundation录制视频时,视频没有音轨,这段代码是怎么回事?readyForMoreMediaData的值一直是return没有,'appendSampleBuffer:'方法没有执行.. .??
1.
AVAssetWriterInput *audioWriterInput = [self audioWriterInput];
if ([self.assetWriter canAddInput:audioWriterInput]) {
[self.assetWriter addInput:audioWriterInput];
}
2.
- (AVAssetWriterInput *)audioWriterInput {
NSDictionary *audioCompressionSettings =
@{
AVEncoderBitRatePerChannelKey:@(28000),
AVFormatIDKey : @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey : @(1),
AVSampleRateKey : @(22050)
};
AVAssetWriterInput *audioWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:audioCompressionSettings];
audioWriterInput.expectsMediaDataInRealTime = YES;
self.audioWriterInput = audioWriterInput;
return audioWriterInput;
}
3.
- (void)appendingAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer {
// readyForMoreMediaData is always return NO
if(self.audioWriterInput.readyForMoreMediaData) {
BOOL success = [self.audioWriterInput appendSampleBuffer:sampleBuffer];
if (success) {
NSLog(@"");
} else {
}
}
}
我真是个傻孩子。我用错了getter方法!!!
当我使用AVFoundation录制视频时,视频没有音轨,这段代码是怎么回事?readyForMoreMediaData的值一直是return没有,'appendSampleBuffer:'方法没有执行.. .??
1.
AVAssetWriterInput *audioWriterInput = [self audioWriterInput];
if ([self.assetWriter canAddInput:audioWriterInput]) {
[self.assetWriter addInput:audioWriterInput];
}
2.
- (AVAssetWriterInput *)audioWriterInput {
NSDictionary *audioCompressionSettings =
@{
AVEncoderBitRatePerChannelKey:@(28000),
AVFormatIDKey : @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey : @(1),
AVSampleRateKey : @(22050)
};
AVAssetWriterInput *audioWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio outputSettings:audioCompressionSettings];
audioWriterInput.expectsMediaDataInRealTime = YES;
self.audioWriterInput = audioWriterInput;
return audioWriterInput;
}
3.
- (void)appendingAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer {
// readyForMoreMediaData is always return NO
if(self.audioWriterInput.readyForMoreMediaData) {
BOOL success = [self.audioWriterInput appendSampleBuffer:sampleBuffer];
if (success) {
NSLog(@"");
} else {
}
}
}
我真是个傻孩子。我用错了getter方法!!!