我将AVVideoAverageBitRateKey设置为900000,但我录制的视频获得了不同的比特率值.总是不同的价值,有时850k,有时780k,810k,从不900k.为什么?
这是我做的设置:
NSNumber *compression = [NSNumber numberWithLong:900000];
AVAsset *videoAsset = [[AVURLAsset alloc] initWithURL:inputURL options:nil];
AVAssetTrack *videoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
CGSize videoSize = videoTrack.naturalSize;
NSDictionary *videoWriterCompressionSettings = [NSDictionary dictionaryWithObjectsAndKeys:compression, AVVideoAverageBitRateKey, nil];
NSDictionary *videoWriterSettings = [NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264,
AVVideoCodecKey, videoWriterCompressionSettings,
AVVideoCompressionPropertiesKey, [NSNumber numberWithFloat:videoSize.width],
AVVideoWidthKey, [NSNumber numberWithFloat:videoSize.height],
AVVideoHeightKey, nil];
AVAssetWriterInput* videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoWriterSettings];
videoWriterInput.expectsMediaDataInRealTime = YES;
videoWriterInput.transform = videoTrack.preferredTransform;
AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:outputURL fileType:AVFileTypeQuickTimeMovie error:nil];
[videoWriter addInput:videoWriterInput];
Run Code Online (Sandbox Code Playgroud)
还没有人回答这个问题,但复活了。比特率是一个复杂的值,与视频方程式中的各种其他变量成正比——与帧率、分辨率和其他因素有关。使用的编解码器。恒定比特率还是可变比特率?等等。其中一些因素本身会产生限制影响,这些影响会传递到最终观察到的平均比特率。请注意,您用来指定比特率的键称为AVVideoAverageBitRateKey
平均值,而不是固定值。请求比特率就像请求一个大概数字,结果应该接近您所请求的值,但可能不完全相同。
归档时间: |
|
查看次数: |
2203 次 |
最近记录: |