mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 21:16:24 +00:00
Take into account ticks_per_frame for framerate calculation. Fixes #575759
This commit is contained in:
parent
983d2f2b36
commit
7ca2836193
3 changed files with 10 additions and 5 deletions
|
@ -189,7 +189,8 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
|
|||
"width", G_TYPE_INT, context->width,
|
||||
"height", G_TYPE_INT, context->height,
|
||||
"framerate", GST_TYPE_FRACTION,
|
||||
context->time_base.den, context->time_base.num, NULL);
|
||||
context->time_base.den / context->ticks_per_frame,
|
||||
context->time_base.num, NULL);
|
||||
} else if (context) {
|
||||
/* so we are after restricted caps in this case */
|
||||
switch (codec_id) {
|
||||
|
@ -1829,6 +1830,7 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
|
|||
/* somehow these seem mixed up.. */
|
||||
context->time_base.den = gst_value_get_fraction_numerator (fps);
|
||||
context->time_base.num = gst_value_get_fraction_denominator (fps);
|
||||
context->ticks_per_frame = 1;
|
||||
|
||||
GST_DEBUG ("setting framerate %d/%d = %lf",
|
||||
context->time_base.den, context->time_base.num,
|
||||
|
|
|
@ -1649,7 +1649,8 @@ gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
|
|||
ffmpegdec->context->time_base.den < 1000)) {
|
||||
GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration");
|
||||
out_duration = gst_util_uint64_scale_int (GST_SECOND,
|
||||
ffmpegdec->context->time_base.num,
|
||||
ffmpegdec->context->time_base.num /
|
||||
ffmpegdec->context->ticks_per_frame,
|
||||
ffmpegdec->context->time_base.den);
|
||||
} else {
|
||||
GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
|
||||
|
|
|
@ -346,6 +346,7 @@ gst_ffmpegenc_getcaps (GstPad * pad)
|
|||
ctx->height = DEFAULT_HEIGHT;
|
||||
ctx->time_base.num = 1;
|
||||
ctx->time_base.den = 25;
|
||||
ctx->ticks_per_frame = 1;
|
||||
ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
|
||||
/* makes it silent */
|
||||
ctx->strict_std_compliance = -1;
|
||||
|
@ -491,6 +492,7 @@ gst_ffmpegenc_setcaps (GstPad * pad, GstCaps * caps)
|
|||
if (!ffmpegenc->context->time_base.den) {
|
||||
ffmpegenc->context->time_base.den = 25;
|
||||
ffmpegenc->context->time_base.num = 1;
|
||||
ffmpegenc->context->ticks_per_frame = 1;
|
||||
} else if ((oclass->in_plugin->id == CODEC_ID_MPEG4)
|
||||
&& (ffmpegenc->context->time_base.den > 65535)) {
|
||||
/* MPEG4 Standards do not support time_base denominator greater than
|
||||
|
@ -515,7 +517,7 @@ gst_ffmpegenc_setcaps (GstPad * pad, GstCaps * caps)
|
|||
ctx = ffmpegenc->context;
|
||||
ctx->gop_size = (ffmpegenc->max_key_interval < 0) ?
|
||||
(-ffmpegenc->max_key_interval
|
||||
* (ctx->time_base.den / ctx->time_base.num))
|
||||
* (ctx->time_base.den * ctx->ticks_per_frame / ctx->time_base.num))
|
||||
: ffmpegenc->max_key_interval;
|
||||
}
|
||||
|
||||
|
@ -636,8 +638,8 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
|
|||
g_return_val_if_fail (frame_size == GST_BUFFER_SIZE (inbuf), GST_FLOW_ERROR);
|
||||
|
||||
ffmpegenc->picture->pts =
|
||||
gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (inbuf),
|
||||
ffmpegenc->context->time_base);
|
||||
gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (inbuf) /
|
||||
ffmpegenc->context->ticks_per_frame, ffmpegenc->context->time_base);
|
||||
|
||||
ffmpegenc_setup_working_buf (ffmpegenc);
|
||||
|
||||
|
|
Loading…
Reference in a new issue