gstreamer-pipelines/gstreamer-record.sh
2025-09-18 21:45:25 +03:00

63 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
# This script record two video streams using gstreamer and saves them to files
# The first video stream is the reference and the second is the encoded stream to be tested
# First stream is coming from decklinkvideosrc
# Second stream is same decklinkvideosrc but encoded using x264enc
# Both streams are saved to files using mp4mux and filesink
if ! command -v gst-launch-1.0 &> /dev/null
then
echo "gstreamer could not be found, please install it."
exit 1
fi
src='decklinkvideosrc device-number=1 connection=1 mode=1080p60 drop-no-signal-frames=true !'
if [ "$1" == "DEBUG" ]; then
src='videotestsrc pattern=smpte !'
fi
name=nvv4l2h264enc
specific=eleph-pr-baseline-preset1-cbr-lossless-10
echo $src
GST_DEBUG_COLOR_MODE=off \
GST_TRACERS="latency(flags=pipeline+element)" \
GST_DEBUG="GST_TRACER:7" \
GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
gst-launch-1.0 -e \
$src \
capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
videoconvert ! capsfilter caps="video/x-raw,format=I420,width=1920,height=1080,framerate=60/1" ! queue ! tee name=t \
t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
t. ! queue ! nvvideoconvert ! \
capsfilter caps="video/x-raw(memory:NVMM),format=I420,width=1920,height=1080" ! \
${name} bitrate=10000000 profile=0 preset-id=1 control-rate=1 tuning-info-id=4 ! \
capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"
# GST_DEBUG_COLOR_MODE=off \
# GST_TRACERS="latency(flags=pipeline+element)" \
# GST_DEBUG="GST_TRACER:7" \
# GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
# gst-launch-1.0 -e \
# $src \
# capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
# videoconvert ! queue ! tee name=t \
# t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
# t. ! queue ! x264enc bitrate=10000 speed-preset=ultrafast tune=zerolatency sliced-threads=true ! \
# capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"
# GST_DEBUG_COLOR_MODE=off \
# GST_TRACERS="latency(flags=pipeline+element)" \
# GST_DEBUG="GST_TRACER:7" \
# GST_DEBUG_FILE=latency_traces-${name}-${specific}.log \
# gst-launch-1.0 -e \
# $src \
# capsfilter caps="video/x-raw,format=UYVY,width=1920,height=1080,framerate=60/1" ! \
# videoconvert ! capsfilter caps="video/x-raw,format=NV12,width=1920,height=1080,framerate=60/1" ! queue ! tee name=t \
# t. ! queue ! filesink location="base-${name}-${specific}.yuv" \
# t. ! queue ! ${name} bitrate=10000 preset=5 rc-lookahead=0 rc-mode=2 zerolatency=true ! \
# capsfilter caps="video/x-h264,profile=baseline" ! h264parse ! mpegtsmux ! filesink location="encoded-${name}-${specific}.mp4"