Save 4 rtsp stream from 4 camera to 1 concatenated video

Hi, I’m trying to save 4 different rtsp stream to one video file. I want to concatenate the 4 stream resolution of 1280x720 to one video of 2560x1440.

I succeed to concatenate the 4 stream to one video file but the video file generated is not compressed. It makes 200Mo for 10secondes. It is too big.
When I checked the codec of the video file created it says ‘Uncompressed packed YUV’

Here is my command :

gst-launch-1.0 -ev \ videomixer name=mix \ sink_1::xpos=0 sink_1::ypos=0 \ sink_2::xpos=1280 sink_2::ypos=0 \ sink_3::xpos=0 sink_3::ypos=720 \ sink_4::xpos=1280 sink_4::ypos=720 \ ! qtmux ! filesink location=mosaic.mp4 \ rtspsrc location='rtsp://192.168.1.19:554/1/h264major' \ ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv \ ! video/x-raw,width=1280,height=720 \ ! mix.sink_1 \ rtspsrc location='rtsp://192.168.1.19:554/1/h264major' \ ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv \ ! video/x-raw,width=1280,height=720 \ ! mix.sink_2 \ rtspsrc location='rtsp://192.168.1.20:554/1/h264major' \ ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv \ ! video/x-raw,width=1280,height=720 \ ! mix.sink_3 \ rtspsrc location='rtsp://192.168.1.20:554/1/h264major' \ ! rtph264depay ! h264parse ! omxh264dec ! nvvidconv \ ! video/x-raw,width=1280,height=720 \ ! mix.sink_4 \
&

PID=$!

sleep 61

kill -INT $PID`

If you have any advice which can help me to reduce the size, to make the file compressed, Thanks!

1 Like

You may try using nvcompositor instead of videomixer.
You may also need to use RTSP2.0 for EOS management.

gst-launch-1.0 -e nvcompositor name=mix background-w=2560 background-h=1440 \
    sink_0::xpos=0 sink_0::ypos=0 sink_0::width=1280 sink_0::height=720  \
    sink_1::xpos=1280 sink_1::ypos=0 sink_1::width=1280 sink_1::height=720 \
    sink_2::xpos=0 sink_2::ypos=720 sink_2::width=1280 sink_2::height=720 \
    sink_3::xpos=1280 sink_3::ypos=720 sink_3::width=1280 sink_3::height=720 \
    ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' ! nvv4l2h264enc insert-vui=1 ! h264parse ! matroskamux ! filesink location=test.mkv sync=false  \
    rtspsrc location=rtsp://127.0.0.1:8554/test default-rtsp-version=32 ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_0      \
    rtspsrc location=rtsp://127.0.0.1:8554/test default-rtsp-version=32 ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_1      \
    rtspsrc location=rtsp://127.0.0.1:8554/test default-rtsp-version=32 ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_2      \
    rtspsrc location=rtsp://127.0.0.1:8554/test default-rtsp-version=32 ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_3

Thanks!
I tried to use your command but it says this :

How can I use rtsp2.0 ?

Maybe the rtsp server in your camera doesn’t support this, but it may not be mandatory.
RTSP1.0 seems working for me for this case:

gst-launch-1.0 -e nvcompositor name=mix background-w=2560 background-h=1440 \
    sink_0::xpos=0 sink_0::ypos=0 sink_0::width=1280 sink_0::height=720  \
    sink_1::xpos=1280 sink_1::ypos=0 sink_1::width=1280 sink_1::height=720 \
    sink_2::xpos=0 sink_2::ypos=720 sink_2::width=1280 sink_2::height=720 \
    sink_3::xpos=1280 sink_3::ypos=720 sink_3::width=1280 sink_3::height=720 \
    ! 'video/x-raw(memory:NVMM),format=RGBA' ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvv4l2h264enc insert-vui=1 profile=2 ! h264parse ! matroskamux ! filesink location=test.mkv sync=false  \
    rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_0      \
    rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_1      \
    rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_2      \
    rtspsrc location=rtsp://127.0.0.1:8554/test ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! 'video/x-raw(memory:NVMM),format=NV12' ! queue ! mix.sink_3

Thanks a lot !! It works as I wish