From cb6f7f03e596dc58b8ba22e760bf95e6ea98922a Mon Sep 17 00:00:00 2001 From: Artur Date: Fri, 5 Sep 2025 17:52:50 +0300 Subject: [PATCH] Container and additional scripts --- .gitignore | 2 ++ container/Dockerfile | 13 ++++++--- container/bmd_install.sh | 53 +++++++++++++++++++++++++++++++++++++ container/build.sh | 4 +++ container/decklinkTest.sh | 8 ++++++ container/nvdummy.sh | 14 ++++++++++ container/nvfull.sh | 19 +++++++++++++ container/run.sh | 14 ++++++++++ decklinkTest.sh | 18 +++++++------ decklinkTestVideoConvert.sh | 11 ++++++++ gst-dummy-sink.sh | 6 +++++ l_nvfull.sh | 14 ++++++++++ nvfull.sh | 14 ++++++++++ r_nvfull.sh | 14 ++++++++++ 14 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 container/bmd_install.sh create mode 100755 container/build.sh create mode 100755 container/decklinkTest.sh create mode 100755 container/nvdummy.sh create mode 100755 container/nvfull.sh create mode 100755 container/run.sh create mode 100755 decklinkTestVideoConvert.sh create mode 100755 gst-dummy-sink.sh create mode 100755 l_nvfull.sh create mode 100755 nvfull.sh create mode 100755 r_nvfull.sh diff --git a/.gitignore b/.gitignore index e69de29..192c459 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log +container/Drivers/* \ No newline at end of file diff --git a/container/Dockerfile b/container/Dockerfile index 086f0db..1a701b3 100644 --- a/container/Dockerfile +++ b/container/Dockerfile @@ -19,14 +19,21 @@ RUN apt-get update && \ # Set environment variables for OpenGL ENV NVIDIA_DRIVER_CAPABILITIES $NVIDIA_DRIVER_CAPABILITIES,video ENV DISPLAY :0 -ENV FILENAME=nvdummy.sh +ENV FILENAME=nvfull.sh +ENV BMD=bmd_install.sh # Copy your pipeline script -COPY ../$FILENAME /app/ +COPY $FILENAME /app/ RUN chmod +x /app/$FILENAME +COPY ./Drivers/ /drivers/ +COPY $BMD /scripts/ +RUN chmod +x /scripts/$BMD && \ + cd /scripts && \ + ./$BMD + # Set working directory WORKDIR /app # Default command to run your pipeline -CMD ["./nvdummy.sh"] +CMD ["sh", "-c", "tail -f /dev/null"] #CMD ["nvidia-smi"] diff --git a/container/bmd_install.sh b/container/bmd_install.sh new file mode 100644 index 0000000..ccecd0b --- /dev/null +++ b/container/bmd_install.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +driversPath='/drivers' + +ls -lah $driversPath + +fetch_sdk() { + echo "Trying to fetch from remote" + let pwd=$PWD + cd $driversPath + wget -r --accept-regex '.*Desktop.*tar' https://vptyp.tech/file/bmd/ || echo "Unable to fetch Driver" + wget -r --accept-regex '.*SDK.*zip' https://vptyp.tech/file/bmd/ || echo "Unable to fetch SDK" + cd $pwd +} + +if [[ -e /drivers ]]; then + echo 'Drivers folder existed!' + sdk_name=$(find $driversPath -name "*SDK*zip" -exec basename {} \;) + driver_name=$(find $driversPath -name "*Desktop*tar*" -exec basename {} \;) + if [[ -n $sdk_name && -n $driver_name ]]; then + printf "Found both files names: \n-%s\n-%s\n" $sdk_name $driver_name + else + printf "Wasn't able to found something: \nSDK name - %s\nDriver name - %s\n" $sdk_name $driver_name + fetch_sdk + sdk_name=$(find $driversPath -name "*SDK*zip" -exec basename {} \;) + driver_name=$(find $driversPath -name "*Desktop*tar*" -exec basename {} \;) + fi +fi + +if ! command -v unzip >/dev/null 2>&1; then + apt-get update + apt-get install -y zip +fi + +if ! command -v tar >/dev/null 2>&1; then + apt-get install -y tar +fi + +if [[ -z "$sdk_name" || -z "$driver_name" ]]; then + echo 'Failed to find drivers' + exit 1 +fi + +cd /drivers +unzip ./$sdk_name -d sdk +mkdir driver +tar -xvzf ./$driver_name -C driver + +cd ./driver/*/deb/x86_64/ + +apt-get install -y libjpeg62 libgl1-mesa-glx libxml2 + +apt-get install -y ./desktopvideo_*.deb diff --git a/container/build.sh b/container/build.sh new file mode 100755 index 0000000..f555b32 --- /dev/null +++ b/container/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +DOCKER_BUILDKIT=1 sudo docker build --build-arg KERNEL_VERSION=$(uname -r) \ + -t deepstream-gst:12.6 . diff --git a/container/decklinkTest.sh b/container/decklinkTest.sh new file mode 100755 index 0000000..04931a0 --- /dev/null +++ b/container/decklinkTest.sh @@ -0,0 +1,8 @@ +gst-launch-1.0 \ +decklinkvideosrc \ + device-number=1 \ + connection=1 \ + mode=auto \ + drop-no-signal-frames=true \ +! videoconvert \ +! autovideosink sync=false \ No newline at end of file diff --git a/container/nvdummy.sh b/container/nvdummy.sh new file mode 100755 index 0000000..f8d7089 --- /dev/null +++ b/container/nvdummy.sh @@ -0,0 +1,14 @@ +#!/bin/bash +GST_DEBUG_COLOR_MODE=off \ + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces.log \ + gst-launch-1.0 videotestsrc pattern=smpte ! \ + capsfilter caps="video/x-raw, width=1920, height=1080, framerate=30/1" ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM)" ! \ + nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=3 profile=2 ! \ + video/x-h264, profile=main ! \ + nvv4l2decoder ! \ + nvvideoconvert ! \ + fakesink diff --git a/container/nvfull.sh b/container/nvfull.sh new file mode 100755 index 0000000..f42edc9 --- /dev/null +++ b/container/nvfull.sh @@ -0,0 +1,19 @@ +#!/bin/bash +GST_DEBUG_COLOR_MODE=off \ + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces.log \ + gst-launch-1.0 decklinkvideosrc \ + device-number=1 \ + connection=1 \ + mode=1080p60 \ + drop-no-signal-frames=true \ + videoconvert ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM)" ! \ + nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=3 profile=2 ! \ + video/x-h264, profile=main ! \ + 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/container/run.sh b/container/run.sh new file mode 100755 index 0000000..f6bc177 --- /dev/null +++ b/container/run.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +sudo docker run \ + --runtime=nvidia \ + --gpus all \ + --device /dev/blackmagic/io0:/dev/blackmagic/io0 \ + --device /dev/blackmagic/io1:/dev/blackmagic/io1 \ + -v ~/git/gstreamer-pipelines/:/app \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e DISPLAY=$DISPLAY \ + --network=host \ + -v ~/git/gstreamer-pipelines/container/Drivers/:/drivers \ + --name deepstream-gst \ + deepstream-gst:12.6 diff --git a/decklinkTest.sh b/decklinkTest.sh index 04931a0..61d67a2 100755 --- a/decklinkTest.sh +++ b/decklinkTest.sh @@ -1,8 +1,10 @@ -gst-launch-1.0 \ -decklinkvideosrc \ - device-number=1 \ - connection=1 \ - mode=auto \ - drop-no-signal-frames=true \ -! videoconvert \ -! autovideosink sync=false \ No newline at end of file +GST_DEBUG=2 \ + gst-launch-1.0 \ + decklinkvideosrc \ + device-number=1 \ + connection=1 \ + mode=auto \ + drop-no-signal-frames=true \ + ! videoconvert \ + ! autovideosink sync=false + diff --git a/decklinkTestVideoConvert.sh b/decklinkTestVideoConvert.sh new file mode 100755 index 0000000..9e6a245 --- /dev/null +++ b/decklinkTestVideoConvert.sh @@ -0,0 +1,11 @@ +GST_DEBUG=2 \ + gst-launch-1.0 \ + decklinkvideosrc \ + device-number=1 \ + connection=1 \ + mode=auto \ + drop-no-signal-frames=true \ + ! nvvideoconvert \ + ! video/x-raw,format=I420,width=1920,height=1080,framerate=60/1 \ + ! rtpvrawpay \ + ! udpsink host=239.239.239.3 port=8889 auto-multicast=true sync=false async=false qos=false diff --git a/gst-dummy-sink.sh b/gst-dummy-sink.sh new file mode 100755 index 0000000..ac474a1 --- /dev/null +++ b/gst-dummy-sink.sh @@ -0,0 +1,6 @@ +#!/bin/bash +gst-launch-1.0 decklinkvideosrc drop-no-signal-frames=true mode=auto device-number=1 connection=1 ! \ + capsfilter caps="video/x-raw,format=(string)UYVY" ! \ + videoconvert ! \ + x264enc ! \ + fakesink diff --git a/l_nvfull.sh b/l_nvfull.sh new file mode 100755 index 0000000..3cbafb6 --- /dev/null +++ b/l_nvfull.sh @@ -0,0 +1,14 @@ +#!/bin/bash +GST_DEBUG_COLOR_MODE=off \ + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces.log \ + gst-launch-1.0 decklinkvideosrc device-number=1 connection=1 mode=1080p60 drop-no-signal-frames=true ! \ + capsfilter caps="video/x-raw,format=(string)UYVY" ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=I420,width=1920,height=1080" ! \ + nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=3 profile=2 ! \ + 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/nvfull.sh b/nvfull.sh new file mode 100755 index 0000000..f9f99a2 --- /dev/null +++ b/nvfull.sh @@ -0,0 +1,14 @@ +#!/bin/bash +GST_DEBUG_COLOR_MODE=off \ + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces.log \ + gst-launch-1.0 decklinkvideosrc device-number=1 connection=1 mode=1080p60 drop-no-signal-frames=true ! \ + capsfilter caps="video/x-raw,format=(string)UYVY" ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=Y444,width=1920,height=1080" ! \ + nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=3 profile=2 ! \ + 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/r_nvfull.sh b/r_nvfull.sh new file mode 100755 index 0000000..2a2ace6 --- /dev/null +++ b/r_nvfull.sh @@ -0,0 +1,14 @@ +#!/bin/bash +GST_DEBUG_COLOR_MODE=off \ + GST_TRACERS="latency(flags=pipeline+element)" \ + GST_DEBUG="GST_TRACER:7" \ + GST_DEBUG_FILE=latency_traces.log \ + gst-launch-1.0 decklinkvideosrc device-number=0 connection=1 mode=1080p60 drop-no-signal-frames=true ! \ + capsfilter caps="video/x-raw,format=(string)UYVY" ! \ + nvvideoconvert ! \ + capsfilter caps="video/x-raw(memory:NVMM),format=I420,width=1920,height=1080" ! \ + nvv4l2h264enc bitrate=10000000 control-rate=1 idrinterval=1 tuning-info-id=3 preset-id=3 profile=2 ! \ + h264parse config-interval=1 ! \ + mpegtsmux ! \ + rtpmp2tpay ! \ + udpsink host=239.239.239.3 port=8890 auto-multicast=true sync=false async=false qos=false