From e61bf9fccf6e8ec354488d357bef426f2fc6442c Mon Sep 17 00:00:00 2001 From: Artur Date: Fri, 31 Oct 2025 16:56:23 +0300 Subject: [PATCH] [gst] new scripts for stereo and mono video stream --- compose-gstreamer-x264.sh | 16 ++++++++++++++++ compose-gstreamer.sh | 30 +++++++++++++++--------------- compose-playback.sh | 25 ++++++++++++------------- compose-sink.sh | 14 ++++++++++++++ gst-stereo.sh | 21 +++++++++++++++++++++ gstNvinfer.sh | 16 ++++++++++++++++ gstPlayback.sh | 24 ++++++++++++------------ gstPlaybackRTPH264.sh | 11 +++++++++++ gstX264.sh | 18 ++++++++++++++++++ gstX264OnlyPay.sh | 16 ++++++++++++++++ videosink/compose-playback.sh | 16 ++++++++++++++++ videosink/gstNvH264.sh | 30 ++++++++++++++++++++++++++++++ videosink/gstNvv4l2h264.sh | 17 +++++++++++++++++ videosink/gstX264.sh | 16 ++++++++++++++++ 14 files changed, 230 insertions(+), 40 deletions(-) create mode 100755 compose-gstreamer-x264.sh mode change 100644 => 100755 compose-playback.sh create mode 100755 compose-sink.sh create mode 100755 gst-stereo.sh create mode 100755 gstNvinfer.sh create mode 100755 gstPlaybackRTPH264.sh create mode 100755 gstX264.sh create mode 100755 gstX264OnlyPay.sh create mode 100755 videosink/compose-playback.sh create mode 100755 videosink/gstNvH264.sh create mode 100755 videosink/gstNvv4l2h264.sh create mode 100755 videosink/gstX264.sh diff --git a/compose-gstreamer-x264.sh b/compose-gstreamer-x264.sh new file mode 100755 index 0000000..8b0ec87 --- /dev/null +++ b/compose-gstreamer-x264.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +gst-launch-1.0 \ + compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=1920 sink_1::ypos=0 background=1 ! \ + 'video/x-raw,width=3840,height=1080,framerate=60/1,format=I420' ! \ + x264enc bitrate=8000 speed-preset=ultrafast tune=zerolatency sliced-threads=true b-adapt=false rc-lookahead=0 ref=0 frame-packing=3 ! \ + rtph264pay ! \ + udpsink host=239.239.239.3 port=2055 auto-multicast=true sync=false async=false qos=false \ + \ + decklinkvideosrc device-number=0 connection=0 mode=1080p60 drop-no-signal-frames=false ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_0 \ + \ + decklinkvideosrc device-number=1 connection=0 mode=1080p60 drop-no-signal-frames=false ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_1 diff --git a/compose-gstreamer.sh b/compose-gstreamer.sh index 3c8f12e..183e74b 100755 --- a/compose-gstreamer.sh +++ b/compose-gstreamer.sh @@ -1,18 +1,18 @@ #!/bin/bash gst-launch-1.0 \ - compositor name=comp sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=1920 sink_1::ypos=0 ! nvvideoconvert ! \ - 'video/x-raw(memory:NVMM),width=3840,height=1080,framerate=60/1,format=I420' ! \ - nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=1 profile=0 ! \ - h264parse config-interval=1 ! \ - mpegtsmux ! \ - rtpmp2tpay ! \ - udpsink host=239.239.239.3 port=2055 auto-multicast=true sync=false async=false qos=false \ -\ - decklinkvideosrc device-number=0 connection=1 mode=1080p60 drop-no-signal-frames=true ! \ - 'video/x-raw,format=(string)UYVY' ! \ - comp.sink_0 \ -\ - decklinkvideosrc device-number=1 connection=1 mode=1080p60 drop-no-signal-frames=true ! \ - 'video/x-raw,format=(string)UYVY' ! \ - comp.sink_1 \ No newline at end of file + compositor name=comp background=1 sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=1920 sink_1::ypos=0 ! \ + capsfilter caps='video/x-raw,width=3840, height=1080,framerate=60/1' ! \ + nvvideoconvert ! \ + capsfilter caps='video/x-raw(memory:NVMM),width=3840,height=1080,framerate=60/1,format=NV12' ! \ + nvv4l2h264enc bitrate=8000000 control-rate=1 idrinterval=256 tuning-info-id=3 preset-id=1 profile=0 ! \ + rtph264pay ! \ + udpsink host=239.239.239.3 port=2055 auto-multicast=true sync=false async=false qos=false \ + \ + decklinkvideosrc device-number=0 connection=0 mode=1080p60 drop-no-signal-frames=false ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_0 \ + \ + decklinkvideosrc device-number=1 connection=0 mode=1080p60 drop-no-signal-frames=false ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_1 diff --git a/compose-playback.sh b/compose-playback.sh old mode 100644 new mode 100755 index 498474c..59595b9 --- a/compose-playback.sh +++ b/compose-playback.sh @@ -1,16 +1,15 @@ #!/bin/bash gst-launch-1.0 udpsrc address=239.239.239.3 port=2055 ! \ - "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T" ! \ - rtpmp2tdepay ! \ - tsdemux ! \ - h264parse ! \ - avdec_h264 ! \ - videoconvert ! \ - tee name=t \ -\ - t. ! queue ! videocrop left=0 right=1920 top=0 bottom=0 ! \ - autovideosink sync=false \ -\ - t. ! queue ! videocrop left=1920 right=0 top=0 bottom=0 ! \ - autovideosink sync=false \ No newline at end of file + "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! \ + rtph264depay ! \ + capsfilter caps='video/x-h264, width=3840,height=1080' ! \ + avdec_h264 ! \ + capsfilter caps='video/x-raw, width=3840,height=1080' ! \ + tee name=t \ + \ + t. ! queue leaky=2 ! videocrop left=0 right=1920 top=0 bottom=0 ! \ + autovideosink sync=false \ + \ + t. ! queue leaky=2 ! videocrop left=1920 right=0 top=0 bottom=0 ! \ + autovideosink sync=false diff --git a/compose-sink.sh b/compose-sink.sh new file mode 100755 index 0000000..e1a20b4 --- /dev/null +++ b/compose-sink.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +gst-launch-1.0 \ + compositor name=comp background=1 sink_0::xpos=0 sink_0::ypos=0 sink_1::xpos=1920 sink_1::ypos=0 ! \ + 'video/x-raw,width=3840,height=2160,framerate=60/1' ! \ + autovideosink sync=false \ + \ + decklinkvideosrc device-number=0 connection=0 mode=1080p60 drop-no-signal-frames=true ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_0 \ + \ + decklinkvideosrc device-number=1 connection=0 mode=1080p60 drop-no-signal-frames=true ! \ + 'video/x-raw,format=(string)UYVY' ! \ + comp.sink_1 diff --git a/gst-stereo.sh b/gst-stereo.sh new file mode 100755 index 0000000..2dc556a --- /dev/null +++ b/gst-stereo.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# + +./gstreamer-record.sh & + +left=$! + +./gstreamer-record-r.sh & +right=$! + +cleanup() { + kill -s SIGINT $left + kill -s SIGINT $right + exit 0 +} + +trap cleanup SIGINT + +while true; do + sleep 1 +done diff --git a/gstNvinfer.sh b/gstNvinfer.sh new file mode 100755 index 0000000..4b6f744 --- /dev/null +++ b/gstNvinfer.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +gst-launch-1.0 filesrc location=$1 ! \ + rawvideoparse format=2 height=540 width=960 framerate=60000/1001 ! \ + clocksync sync-to-first=true ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=RGBA,height=1080,width=1920" ! \ + m.sink_0 nvstreammux name=m batch-size=1 width=1920 height=1080 ! \ + nvinfer config-file-path=config.txt ! \ + nvvideoconvert ! \ + nvsegvisual ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=RGBA" ! \ + nvvideoconvert ! \ + nvv4l2h264enc bitrate=6850000 profile=2 preset-id=3 control-rate=2 idrinterval=256 tuning-info-id=3 ! \ + capsfilter caps="video/x-h264,profile=main" ! h264parse ! mpegtsmux ! \ + filesink location="autotest-nvv4l2h264enc-main-test-base-daVinci.mp4" diff --git a/gstPlayback.sh b/gstPlayback.sh index 388f2f4..894384a 100755 --- a/gstPlayback.sh +++ b/gstPlayback.sh @@ -3,15 +3,15 @@ # Set environment variables for GStreamer latency tracing. # Note: We are using a different log file name to avoid overwriting the sender's log. GST_DEBUG_COLOR_MODE=off \ -GST_TRACERS="latency(flags=pipeline+element)" \ -GST_DEBUG="GST_TRACER:7" \ -GST_DEBUG_FILE=latency_traces_receiver.log \ -gst-launch-1.0 -v \ - udpsrc uri="udp://239.239.239.3:8889" ! \ - "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T" ! \ - rtpmp2tdepay ! \ - tsdemux latency=0 ! \ - h264parse ! \ - avdec_h264 qos=false ! \ - videoconvert ! \ - autovideosink sync=false + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces_receiver.log \ + gst-launch-1.0 -v \ + udpsrc uri="udp://239.239.239.3:8889" ! \ + "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T" ! \ + rtpmp2tdepay ! \ + tsdemux latency=0 ! \ + h264parse ! \ + avdec_h264 qos=false ! \ + videoconvert ! \ + autovideosink sync=false diff --git a/gstPlaybackRTPH264.sh b/gstPlaybackRTPH264.sh new file mode 100755 index 0000000..65f74fa --- /dev/null +++ b/gstPlaybackRTPH264.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Set environment variables for GStreamer latency tracing. +# Note: We are using a different log file name to avoid overwriting the sender's log. +gst-launch-1.0 -v \ + udpsrc uri="udp://239.239.239.3:8889" ! \ + "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" ! \ + rtph264depay ! \ + avdec_h264 qos=false ! \ + videoconvert ! \ + autovideosink sync=false diff --git a/gstX264.sh b/gstX264.sh new file mode 100755 index 0000000..acb02f1 --- /dev/null +++ b/gstX264.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +export GST_DEBUG_COLOR_MODE=off +export GST_TRACERS="latency(flags=pipeline+element)" +export GST_DEBUG="GST_TRACER:7" +export GST_DEBUG_FILE=latency_traces.log + +decklink="decklinkvideosrc drop-no-signal-frames=true mode=1080p60 device-number=1 connection=0" + +gst-launch-1.0 $decklink ! \ + videoconvert n-threads=4 ! \ + capsfilter caps="video/x-raw,width=1920,height=1080" ! \ + x264enc bitrate=20000 speed-preset=ultrafast tune=zerolatency sliced-threads=true b-adapt=false rc-lookahead=0 ref=0 key-int-max=10 ! \ + capsfilter caps="video/x-h264,profile=baseline" ! \ + h264parse config-interval=1 ! \ + mpegtsmux ! \ + rtpmp2tpay ! \ + udpsink host=239.239.239.3 port=8889 auto-multicast=true sync=false async=false qos=false diff --git a/gstX264OnlyPay.sh b/gstX264OnlyPay.sh new file mode 100755 index 0000000..c0548d5 --- /dev/null +++ b/gstX264OnlyPay.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +export GST_DEBUG_COLOR_MODE=off +export GST_TRACERS="latency(flags=pipeline+element)" +export GST_DEBUG="GST_TRACER:7" +export GST_DEBUG_FILE=latency_traces.log + +decklink="decklinkvideosrc drop-no-signal-frames=true mode=1080p60 device-number=1 connection=0" + +gst-launch-1.0 $decklink ! \ + videoconvert n-threads=4 ! \ + capsfilter caps="video/x-raw,width=1920,height=1080" ! \ + x264enc bitrate=4000 speed-preset=ultrafast tune=zerolatency sliced-threads=true b-adapt=false rc-lookahead=0 ref=0 ! \ + capsfilter caps="video/x-h264,profile=baseline" ! \ + rtph264pay ! \ + udpsink host=239.239.239.3 port=8889 auto-multicast=true sync=false async=false qos=false diff --git a/videosink/compose-playback.sh b/videosink/compose-playback.sh new file mode 100755 index 0000000..6e70f7c --- /dev/null +++ b/videosink/compose-playback.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +gst-launch-1.0 udpsrc address=239.239.239.3 port=2055 ! \ + "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T" ! \ + rtpmp2tdepay ! \ + tsdemux ! \ + h264parse ! \ + nvv4l2decoder ! \ + nvvideoconvert ! \ + tee name=t \ + \ + t. ! queue ! videocrop left=0 right=1920 top=0 bottom=0 ! \ + autovideosink sync=false \ + \ + t. ! queue ! videocrop left=1920 right=0 top=0 bottom=0 ! \ + autovideosink sync=false diff --git a/videosink/gstNvH264.sh b/videosink/gstNvH264.sh new file mode 100755 index 0000000..53665ab --- /dev/null +++ b/videosink/gstNvH264.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +export GST_DEBUG_COLOR_MODE=off +export GST_TRACERS="latency(flags=pipeline+element)" +export GST_DEBUG="GST_TRACER:7" +export GST_DEBUG_FILE=latency_traces.log + +decklink="decklinkvideosrc drop-no-signal-frames=true mode=1080p60 device-number=1 connection=0 buffer-size=1 " + +gst-launch-1.0 $decklink ! \ + capsfilter caps="video/x-raw, format=(string)UYVY" ! \ + videoconvert n-threads=4 ! \ + capsfilter caps="video/x-raw,width=1920,height=1080, format=NV12" ! \ + nvh264enc rc-mode=2 bitrate=4000 preset=4 bframes=0 b-adapt=false rc-lookahead=0 zerolatency=true ! \ + capsfilter caps="video/x-h264,profile=baseline" ! \ + nvh264dec ! \ + videoconvert n-threads=4 ! \ + autovideosink + +exit 0 + +gst-launch-1.0 $decklink ! \ + glupload ! \ + glcolorconvert ! \ + capsfilter caps="video/x-raw(memory:GLMemory),width=1280,height=720" ! \ + nvh264enc rc-mode=2 bitrate=10000 preset=3 gop-size=0 bframes=0 b-adapt=false zerolatency=true ! \ + capsfilter caps="video/x-h264,profile=baseline" ! \ + nvh264dec ! \ + glcolorconvert ! \ + glimagesink diff --git a/videosink/gstNvv4l2h264.sh b/videosink/gstNvv4l2h264.sh new file mode 100755 index 0000000..e82d27c --- /dev/null +++ b/videosink/gstNvv4l2h264.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#export GST_DEBUG_COLOR_MODE=off +#export GST_TRACERS="latency(flags=pipeline+element)" +#export GST_DEBUG="GST_TRACER:7" +#export GST_DEBUG_FILE=latency_traces.log + +decklink="decklinkvideosrc drop-no-signal-frames=true mode=1080p60 device-number=0 connection=0 buffer-size=1" + +gst-launch-1.0 $decklink ! \ + capsfilter caps="video/x-raw,format=(string)UYVY" ! \ + nvvideoconvert bl-output=true contiguous-buffers=true output-buffers=1 ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=NV12,width=1920,height=1080" ! \ + nvv4l2h264enc bitrate=4000000 control-rate=2 idrinterval=1 tuning-info-id=3 preset-id=1 profile=0 ! \ + capsfilter caps="video/x-h264, profile=baseline" ! \ + avdec_h264 ! \ + nveglglessink diff --git a/videosink/gstX264.sh b/videosink/gstX264.sh new file mode 100755 index 0000000..3a8b538 --- /dev/null +++ b/videosink/gstX264.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +export GST_DEBUG_COLOR_MODE=off +export GST_TRACERS="latency(flags=pipeline+element)" +export GST_DEBUG="GST_TRACER:7" +export GST_DEBUG_FILE=latency_traces.log + +decklink="decklinkvideosrc drop-no-signal-frames=true mode=1080p60 device-number=1 connection=0" + +gst-launch-1.0 $decklink ! \ + videoconvert n-threads=4 ! \ + capsfilter caps="video/x-raw,width=1920,height=1080" ! \ + x264enc bitrate=4000 speed-preset=ultrafast tune=zerolatency sliced-threads=true b-adapt=false rc-lookahead=0 ref=0 ! \ + capsfilter caps="video/x-h264,profile=baseline" ! \ + avdec_h264 ! \ + autovideosink