vtenc_h264 causing too many Redistribute latency...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

vtenc_h264 causing too many Redistribute latency...

Miki Grof-Tisza
Hi,

I'm having some trouble with the pipeline:
gst-launch-1.0 --gst-debug=*:2,vtenc:4 videotestsrc ! videorate ! video/x-raw, format=UYVY, width=1920, height=1080, framerate=30/1 ! queue ! vtenc_h264 ! fakesink

I’m running gstreamer version 1.12.3 built from source, on a 2017 15” Macbook Pro, w/macOS 10.12.6

The relevant output:
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.154950000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 5 fps 30/1 time 0:00:00.166666665
Redistribute latency...
0:00:00.235169000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 6 fps 30/1 time 0:00:00.199999998
Redistribute latency...
0:00:00.241439000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 5 fps 30/1 time 0:00:00.166666665
Redistribute latency...
0:00:00.253913000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 6 fps 30/1 time 0:00:00.199999998
Redistribute latency...
0:00:00.278467000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 7 fps 30/1 time 0:00:00.233333331
Redistribute latency...
0:00:00.288046000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 6 fps 30/1 time 0:00:00.199999998
Redistribute latency...
0:00:00.371569000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 7 fps 30/1 time 0:00:00.233333331
Redistribute latency...
0:00:03.043466000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 6 fps 30/1 time 0:00:00.199999998
Redistribute latency...
0:00:03.065692000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 5 fps 30/1 time 0:00:00.166666665
Redistribute latency...
0:00:03.090887000 72088 0x7ff6d7010370 INFO                   vtenc vtenc.c:1070:gst_vtenc_update_latency:<vtenc_h264-0> latency status 0 frames 4 fps 30/1 time 0:00:00.133333332
Redistribute latency...


The vtenc_h264 element is calling gst_video_encoder_set_latency() seemingly way too often.  It results in gst-launch printing "Redistribute latency..." quite often (several times per second sometimes).

What's happening seems to be the element keeping track of the underlying encoder's pending frame count.  If the pending frame count ever changes (checked every frame), then it calls gst_video_encoder_set_latency().

Is it not the case that instead of tracking exact latency each frame and forcing a pipeline latency redistribution every time it changes at all, the element should just check if the latency is greater than the currently configured range (checked via call to gst_video_encoder_get_latency()) and only call gst_video_encoder_set_latency() if it's outside the range?

Something like this: (src/applemedia/vtenc.c:1072)

Change:

    gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency);

To:
    GstClockTime min_latency, max_latency;
    gst_video_encoder_get_latency(GST_VIDEO_ENCODER (self), &min_latency, &max_latency);
    if (latency > max_latency){
      gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), min_latency, max_latency);
    }

This does solve my issue with the repeated printing of "Redistribute latency...", but I'm wondering if there's more to it, or if there are any side effects

Any help would be greatly appreciated.

Thanks,
Miki Grof-Tisza




_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: vtenc_h264 causing too many Redistribute latency...

Miki Grof-Tisza
Hi,

I just wanted to correct my proposed solution to the issue.  I just realized the mistake.

Something like this: (src/applemedia/vtenc.c:1072)

Change:

    gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency);

To:
    GstClockTime min_latency, max_latency;
    gst_video_encoder_get_latency(GST_VIDEO_ENCODER (self), &min_latency, &max_latency);
    if (latency > max_latency){
    gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), min_latency, latency);
    }

-Miki

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: vtenc_h264 causing too many Redistribute latency...

Mailing List SVR
Hi,

probably you need to open a bug on:

https://bugzilla.gnome.org/

Platform->GStreamer, component gst-plugins-bad, with your patch attached
to get it discussed and eventually merged upstream,

Nicola

Il 24/10/2017 14:50, Miki Grof-Tisza ha scritto:

> Hi,
>
> I just wanted to correct my proposed solution to the issue.  I just realized the mistake.
>
> Something like this: (src/applemedia/vtenc.c:1072)
>
> Change:
>
>      gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency);
>
> To:
>      GstClockTime min_latency, max_latency;
>      gst_video_encoder_get_latency(GST_VIDEO_ENCODER (self), &min_latency, &max_latency);
>      if (latency > max_latency){
>       gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), min_latency, latency);
>      }
>
> -Miki
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: vtenc_h264 causing too many Redistribute latency...

Miki Grof-Tisza
I opened a bug and attached a patch.
https://bugzilla.gnome.org/show_bug.cgi?id=789415

Thanks,
Miki

On 10/24/17, 9:19 AM, "gstreamer-devel on behalf of Mailing List SVR" <[hidden email] on behalf of [hidden email]> wrote:

    Hi,
   
    probably you need to open a bug on:
   
    https://bugzilla.gnome.org/
   
    Platform->GStreamer, component gst-plugins-bad, with your patch attached
    to get it discussed and eventually merged upstream,
   
    Nicola
   
    Il 24/10/2017 14:50, Miki Grof-Tisza ha scritto:
    > Hi,
    >
    > I just wanted to correct my proposed solution to the issue.  I just realized the mistake.
    >
    > Something like this: (src/applemedia/vtenc.c:1072)
    >
    > Change:
    >
    >      gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency);
    >
    > To:
    >      GstClockTime min_latency, max_latency;
    >      gst_video_encoder_get_latency(GST_VIDEO_ENCODER (self), &min_latency, &max_latency);
    >      if (latency > max_latency){
    >       gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), min_latency, latency);
    >      }
    >
    > -Miki
    >
    > _______________________________________________
    > gstreamer-devel mailing list
    > [hidden email]
    > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
   
    _______________________________________________
    gstreamer-devel mailing list
    [hidden email]
    https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
   

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel