How to "tee" multiple video streams

This is a follow up discussion of Newbie question: how to install OpenCV and setup the path? - Jetson TX2 - NVIDIA Developer Forums
Based on Honey_Patouceul’s method

gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1' ! tee name=yourname ! queue ! nvvidconv ! 'video/x-raw' ! xvimagesink yourname. ! queue ! nvegltransform ! nveglglessink

which produces two streams of videos from a camera.

How to feed a second camera to the second display window?

In general, what’s the “tee” command that can feed (and perhaps “sync” if possible) multiple video streams?

If you want to send one camera to one window and a second one to a second window without having interactions between both streams, probably the easiest way is to launch two gstreamer pipelines (here I use videotestsrc as second source because I only have the onboard camera):

gst-launch-1.0 nvcamerasrc ! nvvidconv ! 'video/x-raw, format=I420, width=640, height=480' ! xvimagesink   |  gst-launch-1.0 videotestsrc ! 'video/x-raw, format=I420, width=640, height=480' ! xvimagesink

or

gst-launch-1.0 nvcamerasrc ! nvvidconv ! 'video/x-raw, format=I420, width=640, height=480' ! xvimagesink     videotestsrc ! 'video/x-raw, format=I420, width=640, height=480' ! xvimagesink

tee would just duplicate a stream at the point it is in the pipeline.

The opposite may be done with videomixer that can mix two sources:

gst-launch-1.0 -ev videomixer name=mix sink_0::xpos=0 sink_1::xpos=640 ! xvimagesink   nvcamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1' ! nvvidconv ! 'video/x-raw, format=I420' ! mix.sink_0      videotestsrc ! 'video/x-raw, width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1' ! mix.sink_1

Hi tmx3,

You can launch second pipeline with different source.
Please note that to use second display window, you should use nvoverlaysink instead of nveglglessink.

If you don’t quite understand display windows of tegra, please also ask.

@WayneWWW, thanks for the direction. I’m still struggling about where to insert the second source in the pipeline. Say I have two cameras, one is at sensor-id=0, and the other is at sensor-id=5.

Here is the command I tried:

gst-launch-1.0 nvcamerasrc sensor-id=0 ! ‘video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1’ ! tee name=yourname ! queue ! nvvidconv ! ‘video/x-raw’ ! xvimagesink yourname. ! queue ! nvcamerasrc sensor-id=5 ! ‘video/x-raw(memory:NVMM), width=640, height=480, framerate=30/1, format=NV12’ ! nvoverlaysink

But it failed with a prompt:

WARNING: erroneous pipeline: could not link queue1 to nvcamerasrc1

Can you tell what’s wrong in the command?

Not sure why you are using tee… the error is that queue tries to output into nvcamerasrc which is a pure source, it has no input. Simply try

gst-launch-1.0 nvcamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1' ! nvvidconv ! 'video/x-raw' ! xvimagesink              nvcamerasrc sensor-id=5 ! 'video/x-raw(memory:NVMM), width=640, height=480, framerate=30/1, format=NV12' ! nvoverlaysink

However, nvoverlaysink may use the full screen, not sure you’ll be able to see the xvimagesink window. This may be easier:

gst-launch-1.0 nvcamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1' ! nvvidconv ! 'video/x-raw' ! xvimagesink              nvcamerasrc sensor-id=5 ! 'video/x-raw(memory:NVMM), width=640, height=480, framerate=30/1, format=NV12' ! nvoverlaysink overlay-w=640 overlay-h=480

@Honey_patouceul, it works! Thanks for showing the details. As far as using “tee” or not, it’s not really a concern. I just wanted to find a way to display two cameras in a single command.

Using “nvoverlaysink” will set the display at a fixed position. I found that “nveglglessink” can be used as well if a floating window is desirable. Here is the command:

gst-launch-1.0 nvcamerasrc sensor-id=0 ! ‘video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1’ ! nvvidconv ! ‘video/x-raw’ ! xvimagesink nvcamerasrc sensor-id=5 ! ‘video/x-raw(memory:NVMM), width=640, height=480, framerate=30/1, format=NV12’ ! nvvidconv flip-method=0 ! nvegltransform ! nveglglessink