Hi,
I’m currently using this command to record the video stream from 4 rtsp cameras and to concatenate the 4 stream to create one video file:
gst-launch-1.0 nvcompositor name=mix \
sink_0::xpos=0 sink_0::ypos=0 sink_0::width=$3 sink_0::height=$4 \
sink_1::xpos=$3 sink_1::ypos=0 sink_1::width=$3 sink_1::height=$4 \
sink_2::xpos=0 sink_2::ypos=$4 sink_2::width=$3 sink_2::height=$4 \
sink_3::xpos=$3 sink_3::ypos=$4 sink_3::width=$3 sink_3::height=$4 \
! "video/x-raw(memory:NVMM),format=RGBA,width=$(($3*2)),height=$(($4*2))" ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12" ! nvv4l2h264enc insert-vui=1 profile=2 \
! h264parse ! video/x-h264,width=$(($3*2)),height=$(($4*2)),framerate=$5/1 ! matroskamux ! filesink location=$6$1.mp4 sync=false \
rtspsrc location=rtsp://192.168.2.18:554/1/h264major ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12,width=$3,height=$4,pixel-aspect-ratio=1/1" ! queue ! mix.sink_0 \
rtspsrc location=rtsp://192.168.2.19:554/1/h264major ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12,width=$3,height=$4,pixel-aspect-ratio=1/1" ! queue ! mix.sink_1 \
rtspsrc location=rtsp://192.168.2.20:554/1/h264major ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12,width=$3,height=$4,pixel-aspect-ratio=1/1" ! queue ! mix.sink_2 \
rtspsrc location=rtsp://192.168.2.21:554/1/h264major ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12,width=$3,height=$4,pixel-aspect-ratio=1/1" ! queue ! mix.sink_3
This command run perfectly but I have 2 issues :
-
When I play my video file there is a problem in the ending of the video, it likes the video never finished. There is no fix duration of the video.
-
Second issue is if a camera is not connected or broken my command stops and doesn’t record. Is it possible to find a way to record only on 3 cameras and ignore the one which doesn’t work ? Like a parameter to add in the command ?
The error for the second issue :
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc2: Could not open resource for reading and writing.
Additional debug info:
gstrtspsrc.c(7469): gst_rtspsrc_retrieve_sdp (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc2:
Failed to connect. (Generic error)