mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
FS-9487 #resolve [Add CBR param to video file recording params]
This commit is contained in:
parent
1e867a85f8
commit
d3ee9adfd1
@ -321,6 +321,7 @@ typedef struct switch_mm_s {
|
|||||||
int vb;
|
int vb;
|
||||||
int vw;
|
int vw;
|
||||||
int vh;
|
int vh;
|
||||||
|
int cbr;
|
||||||
float fps;
|
float fps;
|
||||||
float source_fps;
|
float source_fps;
|
||||||
int vbuf;
|
int vbuf;
|
||||||
|
@ -353,7 +353,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||||||
/* Resolution must be a multiple of two. */
|
/* Resolution must be a multiple of two. */
|
||||||
c->width = mst->width;
|
c->width = mst->width;
|
||||||
c->height = mst->height;
|
c->height = mst->height;
|
||||||
c->bit_rate = switch_calc_bitrate(c->width, c->height, 2, fps) * 1024;
|
c->bit_rate = mm->vb;
|
||||||
mst->st->time_base.den = 1000;
|
mst->st->time_base.den = 1000;
|
||||||
mst->st->time_base.num = 1;
|
mst->st->time_base.num = 1;
|
||||||
c->time_base.den = 1000;
|
c->time_base.den = 1000;
|
||||||
@ -409,6 +409,13 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (mm->cbr) {
|
||||||
|
c->rc_min_rate = c->bit_rate;
|
||||||
|
c->rc_max_rate = c->bit_rate;
|
||||||
|
c->rc_buffer_size = c->bit_rate;
|
||||||
|
c->qcompress = 0;
|
||||||
|
} else {
|
||||||
c->gop_size = 250; // g=250
|
c->gop_size = 250; // g=250
|
||||||
c->keyint_min = 25; // keyint_min=25
|
c->keyint_min = 25; // keyint_min=25
|
||||||
c->i_quant_factor = 0.71; // i_qfactor=0.71
|
c->i_quant_factor = 0.71; // i_qfactor=0.71
|
||||||
@ -417,7 +424,7 @@ static switch_status_t add_stream(MediaStream *mst, AVFormatContext *fc, AVCodec
|
|||||||
c->qmax = 31; // qmax=31
|
c->qmax = 31; // qmax=31
|
||||||
c->max_qdiff = 4; // qdiff=4
|
c->max_qdiff = 4; // qdiff=4
|
||||||
av_opt_set_int(c->priv_data, "crf", 18, 0);
|
av_opt_set_int(c->priv_data, "crf", 18, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (codec_id == AV_CODEC_ID_VP8) {
|
if (codec_id == AV_CODEC_ID_VP8) {
|
||||||
av_set_options_string(c, "quality=realtime", "=", ":");
|
av_set_options_string(c, "quality=realtime", "=", ":");
|
||||||
@ -1753,7 +1760,9 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
|
|||||||
handle->mm.ab = 128;
|
handle->mm.ab = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!handle->mm.vb) {
|
||||||
handle->mm.vb = switch_calc_bitrate(handle->mm.vw, handle->mm.vh, 1, handle->mm.fps);
|
handle->mm.vb = switch_calc_bitrate(handle->mm.vw, handle->mm.vh, 1, handle->mm.fps);
|
||||||
|
}
|
||||||
|
|
||||||
if (fmt->video_codec != AV_CODEC_ID_NONE) {
|
if (fmt->video_codec != AV_CODEC_ID_NONE) {
|
||||||
const AVCodecDescriptor *desc;
|
const AVCodecDescriptor *desc;
|
||||||
|
@ -142,6 +142,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((val = switch_event_get_header(fh->params, "cbr"))) {
|
||||||
|
tmp = switch_true(val);
|
||||||
|
fh->mm.cbr = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if ((val = switch_event_get_header(fh->params, "vb"))) {
|
if ((val = switch_event_get_header(fh->params, "vb"))) {
|
||||||
tmp = atoi(val);
|
tmp = atoi(val);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user