octx->width = vs->vid_width ? vs->vid_width : ictx->width;
octx->height = vs->vid_height ? vs->vid_height : ictx->height;
octx->gop_size = 25;
- octx->time_base.den = ictx->time_base.den;
- octx->time_base.num = ictx->time_base.num;
octx->has_b_frames = ictx->has_b_frames;
+ // Encoder uses "time_base" for bitrate calculation, but "time_base" from decoder
+ // will be deprecated in the future, therefore calculate "time_base" from "framerate" if available.
+ octx->ticks_per_frame = ictx->ticks_per_frame;
+ if (ictx->framerate.num != 0 && ictx->framerate.den != 0) {
+ octx->time_base = av_inv_q(av_mul_q(ictx->framerate, av_make_q(ictx->ticks_per_frame, 1)));
+ } else {
+ octx->time_base = ictx->time_base;
+ }
+
switch (ts->ts_type) {
case SCT_MPEG2VIDEO:
octx->codec_id = AV_CODEC_ID_MPEG2VIDEO;