This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5728: Ducati H.264 encoder latency

Part Number: AM5728

Hi,

I am receiving a 30 fps/1080p MJPEG stream over RTP to the AM5728, and I want to transcode to h264 and retransmit to another device. I'm finding that there is some latency being introduced in ducatih264enc. How can I adjust the properties to minimize the overall latency? My sending pipeline (on AM5728) looks like:

gst-launch-1.0 -v udpsrc port=1234 caps="application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, ssrc=(guint)2823054885" ! rtpjitterbuffer latency=20 drop-on-latency=false ! rtpjpegdepay ! jpegparse ! ducatijpegdec ! vpe ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! ducatih264enc ! h264parse ! rtph264pay ! udpsink host=192.168.100.114 port=1234

I've tried setting the ducatih264enc properties : rate-preset=1 hrd-buffer-size=4096 , but the latency is still noticeable.

My receiving pipeline (on other device) is:

gst-launch-1.0 -v udpsrc port=1234 ! application/x-rtp,encoding-name=H264,payload=96 ! rtpjitterbuffer latency=100 drop-on-latency=false ! rtph264depay ! h264parse ! vaapidecode ! fpsdisplaysink sync=false

Thank you,

Vishal

  • Hello,

    You could try to set latency=400 drop-on-latency=true;
    Add few queue elements;
    Set level;
    gst-launch-1.0 -v udpsrc port=1234 caps="application/x-rtp, media=(string)video, payload=(int)26, clock-rate=(int)90000, ssrc=(guint)2823054885" ! rtpjitterbuffer latency=400 drop-on-latency=true ! queue ! rtpjpegdepay ! jpegparse ! queue ! ducatijpegdec ! queue ! vpe ! video/x-raw, format=NV12, width=1920, height=1080, framerate=30/1 ! queue ! ducatih264enc level=level-51 ! h264parse ! queue ! rtph264pay ! udpsink host=192.168.100.114 port=1234

    BR
    Margarita
  • Hello,

    Please set inter-interval=1 also.

    BR
    Margarita
  • Hi Margarita,

    Thank you for your quick reply.

    I have tried your new pipeline as well as with inter-interval=1, but the results are not steady, and the latency is still significant.

    If it helps, I've been able to get this working (with reasonably low latency) with keeping the encoding as MJPEG and sending it from AM5728 to the other device. The latency seems to be introduced when I attempt to transcode the MJPEG to h264 and then stream over rtp.

    Thanks,
  • Hello,

    Do you observe any improvement if you add mpegtsmux element after h264parse(add queue element also)?

    BR
    Margarita
  • Hello,

    I am closing this thread.

    BR
    Margarita
  • Hello Margarita,

    Apologies for the delayed reply. I tried the approach you suggested with muxing to MPEGTS and then using that over RTP, but I got very similar if not identical results to just H264 over RTP. My understanding is that the latency is coming from the ducatih264enc or one of the elements  related to the transcoding (h264parse perhaps?).

    Is there a way to pin point where that extra latency is coming from?

    And do you know of any other property modifications that could reduce latency in the h264 transcoding?

    Thank you,

    Vishal

  • Hello,

    Could you check on your side the CPU load(top command). One of the reasons could be high CPU load.
    I would recommend you to try to remove rtpjitterbuffer. But if you do not observe improvement please set drop-on-latency=true. In this cases please set level=level-41 and inter-interval=1 which means no B frames.
    Could you try to change the caps filter after vpe with lower resolution?

    BR
    Margarita
  • One more note the latency in this case could be generated from receiving side also. So I would recommend you to add few queues on receiving side also. Replace the decode with avdec_h264. Replace fpsdisplaysink also.
    Hope this helps.

    BR
    Margarita