I'm working on moving our application from some proprietary codec to iOS native h264 encoder (VideoToolbox.framework) and have question:
Is there exists way to set bitrate or datarate for compressed data ?
Here is how I creating encoder session:
CFMutableDictionaryRef sessionAttributes = CFDictionaryCreateMutable(
NULL,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
//** bitrate
int fixedBitrate = bitrate; // 2000 * 1024 -> assume 2 Mbits/s
CFNumberRef bitrateNum = CFNumberCreate(NULL, kCFNumberSInt32Type, &fixedBitrate);
CFDictionarySetValue(sessionAttributes, kVTCompressionPropertyKey_AverageBitRate, bitrateNum);
CFRelease(bitrateNum);
CFDictionarySetValue(sessionAttributes, kVTCompressionPropertyKey_ProfileLevel, kVTProfileLevel_H264_High_AutoLevel);
CFDictionarySetValue(sessionAttributes, kVTCompressionPropertyKey_RealTime, kCFBooleanTrue);
OSStatus error = VTCompressionSessionCreate(kCFAllocatorDefault,
width,
height,
kCMVideoCodecType_H264,
sessionAttributes,
NULL,
kCFAllocatorDefault,
&EncoderCallback,
this, *outputCallbackRefCon,
&m_EncoderSession);
I'm played a lot with different values of kVTCompressionPropertyKey_AverageBitRate
but this does nothing for me, I also tried kVTCompressionPropertyKey_DataRateLimits
with different values but also without any luck.
Any ideas, suggestions are welcome