Commit a77698c8 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Do not change video size when changing the bitrate while already encoding video.

parent ff24a844
......@@ -937,20 +937,13 @@ static int enc_get_br(MSFilter *f, void *arg){
static int enc_set_br(MSFilter *f, void *arg) {
EncState *s = (EncState *)f->data;
int br = *(int *)arg;
const MSVideoConfiguration *current_vconf = get_vconf_list(s);
const MSVideoConfiguration *closer_to_best_vconf = NULL;
MSVideoConfiguration best_vconf;
while (closer_to_best_vconf == NULL) {
if ((br >= current_vconf->required_bitrate) || (current_vconf->required_bitrate == 0)) {
closer_to_best_vconf = current_vconf;
} else {
current_vconf++;
}
if (s->av_context.codec != NULL) {
/* Encoding is already ongoing, do not change video size, only bitrate. */
s->vconf.required_bitrate = br;
} else {
MSVideoConfiguration best_vconf = ms_video_find_best_configuration_for_bitrate(s->vconf_list, br);
enc_set_configuration(f, &best_vconf);
}
memcpy(&best_vconf, closer_to_best_vconf, sizeof(best_vconf));
best_vconf.required_bitrate = br;
enc_set_configuration(f, &best_vconf);
return 0;
}
......
......@@ -342,11 +342,15 @@ static int enc_get_br(MSFilter *f, void*data){
}
static int enc_set_br(MSFilter *f, void*data) {
MSVideoConfiguration best_vconf;
EncState *s = (EncState *)f->data;
int br = *(int *)data;
best_vconf = ms_video_find_best_configuration_for_bitrate(s->vconf_list, br);
enc_set_configuration(f, &best_vconf);
if (s->ready) {
/* Encoding is already ongoing, do not change video size, only bitrate. */
s->vconf.required_bitrate = br;
} else {
MSVideoConfiguration best_vconf = ms_video_find_best_configuration_for_bitrate(s->vconf_list, br);
enc_set_configuration(f, &best_vconf);
}
return 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