If for some reason the encoder produces frames with a pts higher than
the input one, we were dropping all the video encoder frames and ended
up crashing when trying to access the pts of a NULL pointer returned by
gst_video_encoder_get_oldest_frame().
I hit this scenario by feeding a decreasing timestamp to vp8enc which
seem to confuse the encoder.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2405>
if (frame)
gst_video_encoder_finish_frame (video_encoder, frame);
frame = gst_video_encoder_get_oldest_frame (video_encoder);
+ if (!frame) {
+ GST_WARNING_OBJECT (encoder,
+ "vpx pts %" G_GINT64_FORMAT
+ " does not match input frames, discarding", pkt->data.frame.pts);
+ goto out;
+ }
+
pts =
gst_util_uint64_scale (frame->pts,
encoder->cfg.g_timebase.den,
pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
}
+
+out:
g_mutex_unlock (&encoder->encoder_lock);
return ret;