Commit 04afbb78 authored by Simon Morlat's avatar Simon Morlat

fix SET_BITRATE resulting in errors due to bitrate set before max_bitrate.

parent 87b973e0
......@@ -314,6 +314,7 @@ void MSOpenH264Encoder::generateKeyframe()
{
int ret=0;
if (mFrameCount>0){
ms_message("Requesting OpenH264 to generate a keyframe");
ret = mEncoder->ForceIntraFrame(true);
}else ms_message("ForceIntraFrame() ignored since no frame has been generated yet.");
......@@ -361,14 +362,17 @@ void MSOpenH264Encoder::applyBitrate()
targetBitrateInfo.iLayer = maxBitrateInfo.iLayer = SPATIAL_LAYER_0;
targetBitrateInfo.iBitrate = targetBitrate;
maxBitrateInfo.iBitrate = maxBitrate;
int ret = mEncoder->SetOption(ENCODER_OPTION_BITRATE, &targetBitrateInfo);
int ret = mEncoder->SetOption(ENCODER_OPTION_MAX_BITRATE, &maxBitrateInfo);
if (ret != 0) {
ms_error("OpenH264 encoder: Failed setting maximum bitrate: %d", ret);
}
ret = mEncoder->SetOption(ENCODER_OPTION_BITRATE, &targetBitrateInfo);
if (ret != 0) {
ms_error("OpenH264 encoder: Failed setting bitrate: %d", ret);
}
ret = mEncoder->SetOption(ENCODER_OPTION_MAX_BITRATE, &maxBitrateInfo);
if (ret != 0) {
ms_error("OpenH264 encoder: Failed setting maximum bitrate: %d", ret);
}
float frameRate = mVConf.fps;
ret = mEncoder->SetOption(ENCODER_OPTION_FRAME_RATE, &frameRate);
if (ret != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment