diff options
author | Mario Sanchez Prada <mario@endlessm.com> | 2016-04-22 15:02:16 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-04-23 13:56:56 +0100 |
commit | 87403135041470b4fa101dd2930777b6d3ea2cb6 (patch) | |
tree | f57e1171584c61dfef234457225f99869851ca8b | |
parent | 4ba6214d3a038fb81e27cafa4dc2b41f8d5f3246 (diff) |
vpxenc: Properly handle frames with too low duration
When a frame's duration is too low, calling gst_util_uint64_scale()
to scale its value can result into it being truncated to zero, which
will cause the vpx encoder to return an VPX_CODEC_INVALID_PARAM error
when trying to encode.
To prevent this from happening, we simply ignore the duration when
encoding if it becomes zero after scaling, logging a warning message.
https://bugzilla.gnome.org/show_bug.cgi?id=765391
-rw-r--r-- | ext/vpx/gstvpxenc.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/vpx/gstvpxenc.c b/ext/vpx/gstvpxenc.c index 11d4cc11a..003d4640f 100644 --- a/ext/vpx/gstvpxenc.c +++ b/ext/vpx/gstvpxenc.c @@ -1888,7 +1888,17 @@ gst_vpx_enc_handle_frame (GstVideoEncoder * video_encoder, duration = gst_util_uint64_scale (frame->duration, encoder->cfg.g_timebase.den, encoder->cfg.g_timebase.num * (GstClockTime) GST_SECOND); - encoder->last_pts += frame->duration; + + if (duration > 0) { + encoder->last_pts += frame->duration; + } else { + /* We force the path ignoring the duration if we end up with a zero + * value for duration after scaling (e.g. duration value too small) */ + GST_WARNING_OBJECT (encoder, + "Ignoring too small frame duration %" GST_TIME_FORMAT, + GST_TIME_ARGS (frame->duration)); + duration = 1; + } } else { duration = 1; } |