mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 04:22:27 +00:00
mpeg2enc: report a latency
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1491>
This commit is contained in:
parent
2dfceac9fc
commit
674ad01016
1 changed files with 26 additions and 0 deletions
|
@ -559,12 +559,38 @@ gst_mpeg2enc_loop (GstVideoEncoder * video_encoder)
|
||||||
|
|
||||||
if (!enc->encoder) {
|
if (!enc->encoder) {
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
GstClockTime latency;
|
||||||
|
GstVideoInfo *info = &enc->input_state->info;
|
||||||
|
|
||||||
/* create new encoder with these settings */
|
/* create new encoder with these settings */
|
||||||
enc->encoder = new GstMpeg2Encoder (enc->options, GST_ELEMENT (video_encoder),
|
enc->encoder = new GstMpeg2Encoder (enc->options, GST_ELEMENT (video_encoder),
|
||||||
gst_pad_get_current_caps(video_encoder->sinkpad));
|
gst_pad_get_current_caps(video_encoder->sinkpad));
|
||||||
|
|
||||||
ret = enc->encoder->setup ();
|
ret = enc->encoder->setup ();
|
||||||
|
|
||||||
|
/* We must have a fixated max GOP size after setting up */
|
||||||
|
g_assert (enc->options->max_GOP_size != -1);
|
||||||
|
|
||||||
|
/* mjpeg tools outputs encoded data on a GOP basis, our latency is
|
||||||
|
* thus at least max_GOP_size. It also introduces a 5-frame delay on
|
||||||
|
* top of that, this was determined empirically, a surface level inspection
|
||||||
|
* of the code didn't show where and why that delay is introduced exactly,
|
||||||
|
* and this is not specifically documented, but it needs to be taken
|
||||||
|
* into account when calculating the latency
|
||||||
|
*/
|
||||||
|
if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
|
||||||
|
/* Assume 25fps for unknown framerates. Better than reporting
|
||||||
|
* that we introduce no latency while we actually do
|
||||||
|
*/
|
||||||
|
latency = gst_util_uint64_scale (enc->options->max_GOP_size + 5,
|
||||||
|
1 * GST_SECOND, 25);
|
||||||
|
} else {
|
||||||
|
latency = gst_util_uint64_scale (enc->options->max_GOP_size + 5,
|
||||||
|
GST_VIDEO_INFO_FPS_D (info) * GST_SECOND, GST_VIDEO_INFO_FPS_N (info));
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_video_encoder_set_latency (video_encoder, latency, latency);
|
||||||
|
|
||||||
/* SeqEncoder init requires at least two frames */
|
/* SeqEncoder init requires at least two frames */
|
||||||
enc->encoder->init ();
|
enc->encoder->init ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue