I'm now using Videotoolbox to deal with h.264 encoding.
And I found a sample code and it works fine :
#define VTB_HEIGHT 480
#define VTB_WIDTH 640
int bitRate = VTB_WIDTH * VTB_HEIGHT * 3 * 4 * 8;
CFNumberRef bitRateRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bitRate);
VTSessionSetProperty(encodingSession,
kVTCompressionPropertyKey_AverageBitRate,
bitRateRef);
CFRelease(bitRateRef);
int bitRateLimit = bitRate / 8;
CFNumberRef bitRateLimitRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type,
&bitRateLimit);
VTSessionSetProperty(encodingSession,
kVTCompressionPropertyKey_DataRateLimits,
bitRateLimitRef);
CFRelease(bitRateLimitRef);
But these two lines, I don't understand:
int bitRate = VTB_WIDTH * VTB_HEIGHT * 3 * 4 * 8;
int bitRateLimit = bitRate / 8;
What's the right way to use them?
hope someone can tell me.
Thanks for your time!