Efficient use of Nvv4l2h264 encoder in gstreamer pipeline

Let’s say we have two different sinks in a pipeline for example the following

gst-launch-1.0 -e \
videotestsrc pattern=ball do-timestamp=true is-live=true ! video/x-raw, width=800, height=600 framerate=30/1 ! queue ! \
nvvidconv ! \
tee name=t \
t. ! queue ! nvv4l2h264enc ! h264parse ! qtmux ! filesink location=example.mp4 sync=false \
t. ! queue ! nvv4l2h264enc ! h264parse ! matroskamux ! tcpserversink port=8000

I have used Nvv4l2h264 twice in this pipeline and worked fine but my question is more of a performance related. For this resolution the encoder might work but it feels like its speed reduced by half now hardware probably tries to convert the same image twice. Does gstreamer optimize this behaviour ?

On the other half this pipeline also works

gst-launch-1.0 -e \
videotestsrc pattern=ball do-timestamp=true is-live=true ! video/x-raw, width=800, height=600 framerate=30/1 ! queue ! \
nvvidconv ! \
nvv4l2h264enc ! h264parse !\
tee name=t \
t. ! queue ! qtmux ! filesink location=example.mp4 sync=false \
t. ! queue ! matroskamux ! tcpserversink port=8000

Which seems an optimizated version of above.
Are these the same or the latter is more efficient use of encoder?

If both sinks need the same resolution/profile of H264 encoding, yes it would be better to only encode once.
In this case, I suppose both qtmux and matroskamux use avc H264 stream-format.
In case one of the sink would require H264 byte stream format, you may use tee after decoder and fork into 2 h264parse plugins.
(It might just be a typo, be aware that your last pipeline above lacks a space before tee).

2 Likes

Hi,
As Honey Patouceul suggests, it is better to encode once and then send to TCP along with saving to a local file. The second pipeline looks better for this use-case.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.