mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
x264enc: Fix setting latency
Fixes setting latency when framerate is dynamic and round up the latency to avoid rounding issues.
This commit is contained in:
parent
6e920bc4aa
commit
c3cc8d416c
1 changed files with 18 additions and 3 deletions
|
@ -1371,9 +1371,24 @@ static void
|
|||
gst_x264_enc_set_latency (GstX264Enc * encoder)
|
||||
{
|
||||
GstVideoInfo *info = &encoder->input_state->info;
|
||||
GstClockTime latency = gst_util_uint64_scale (GST_SECOND * info->fps_d,
|
||||
x264_encoder_maximum_delayed_frames (encoder->x264enc), info->fps_n);
|
||||
gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder), latency, latency);
|
||||
|
||||
if (info->fps_n) {
|
||||
GstClockTime latency;
|
||||
gint max_delayed_frames;
|
||||
max_delayed_frames = x264_encoder_maximum_delayed_frames (encoder->x264enc);
|
||||
latency = gst_util_uint64_scale_ceil (GST_SECOND * info->fps_d,
|
||||
max_delayed_frames, info->fps_n);
|
||||
|
||||
GST_INFO ("Updating latency to %" GST_TIME_FORMAT " (%d frames)",
|
||||
GST_TIME_ARGS (latency), max_delayed_frames);
|
||||
|
||||
gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder), latency,
|
||||
latency);
|
||||
} else {
|
||||
/* We can't do live as we don't know our latency */
|
||||
gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder),
|
||||
GST_CLOCK_TIME_NONE, GST_CLOCK_TIME_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue