Exemplo n.º 1
0
static void
gst_x265_enc_set_latency (GstX265Enc * encoder)
{
  GstVideoInfo *info = &encoder->input_state->info;

  if (info->fps_n) {
    GstClockTime latency;
    gint max_delayed_frames;

    // FIXME get a real value from the encoder, this is currently not exposed
    max_delayed_frames = 5;
    latency = gst_util_uint64_scale_ceil (GST_SECOND * info->fps_d,
        max_delayed_frames, info->fps_n);

    GST_INFO_OBJECT (encoder,
        "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),
        0, GST_CLOCK_TIME_NONE);
  }
}
Exemplo n.º 2
0
static void
gst_x265_enc_set_latency (GstX265Enc * encoder)
{
  GstVideoInfo *info = &encoder->input_state->info;
  gint max_delayed_frames;
  GstClockTime latency;

  /* FIXME get a real value from the encoder, this is currently not exposed */
  if (encoder->tune > 0 && encoder->tune <= G_N_ELEMENTS (x265_tune_names) &&
      strcmp (x265_tune_names[encoder->tune + 1], "zerolatency") == 0)
    max_delayed_frames = 0;
  else
    max_delayed_frames = 5;

  if (info->fps_n) {
    latency = gst_util_uint64_scale_ceil (GST_SECOND * info->fps_d,
        max_delayed_frames, info->fps_n);
  } else {
    /* FIXME: Assume 25fps. This is better than reporting no latency at
     * all and then later failing in live pipelines
     */
    latency = gst_util_uint64_scale_ceil (GST_SECOND * 1,
        max_delayed_frames, 25);
  }

  GST_INFO_OBJECT (encoder,
      "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);
}
Exemplo n.º 3
0
static void
gst_av1_enc_set_latency (GstAV1Enc * av1enc)
{
  GstClockTime latency;
  gint fps_n, fps_d;

  if (av1enc->input_state->info.fps_n && av1enc->input_state->info.fps_d) {
    fps_n = av1enc->input_state->info.fps_n;
    fps_d = av1enc->input_state->info.fps_d;
  } else {
    fps_n = 25;
    fps_d = 1;
  }

  latency =
      gst_util_uint64_scale (av1enc->aom_cfg.g_lag_in_frames * GST_SECOND,
      fps_d, fps_n);
  gst_video_encoder_set_latency (GST_VIDEO_ENCODER (av1enc), latency, latency);

  GST_DEBUG_OBJECT (av1enc, "Latency set to %" GST_TIME_FORMAT
      " = %d frames at %d/%d fps ", GST_TIME_ARGS (latency),
      av1enc->aom_cfg.g_lag_in_frames, fps_n, fps_d);
}