Gstreamer commands and scripts

Some gstreamer pipelines, both general purpose and specific for a camera that streams over SRT.

#Commands

#Bearable speaker-test

speaker-test -w /usr/share/sounds/alsa/Side_Right.wav -t wav

#Play a sample file with gstreamer

gst-launch-1.0 playbin uri=file:///usr/share/sounds/alsa/Side_Right.wav

#Play an MP3 file with a low-pass filter with gstreamer

gst-launch-1.0 filesrc location=ocean_x.mp3 ! mpegaudioparse ! mpg123audiodec ! audiocheblimit mod

e=low-pass cutoff=1000 ! autoaudiosink

#Camera plus audio that streams over SRT

FRAMERATE=10

LIBCAMERA_RPI_TUNING_FILE='/usr/share/libcamera/ipa/rpi/vc4/ov5647_noir.json' \
gst-launch-1.0 --quiet --gst-fatal-warnings --gst-debug-disable \
  libcamerasrc \
  ! video/x-raw,format=NV12,interlace-mode=progressive,width=1280,height=960,framerate="${FRAMERATE}"/1 \
  ! videoconvertscale method=mitchell \
  ! video/x-raw,format=GRAY8,width=${WIDTH},height=${HEIGHT} \
  ! mux. \
  alsasrc device=plughw:CARD=sndrpigooglevoi,DEV=0 \
  ! audio/x-raw,format=S32LE,rate=48000 \
  ! mux. \
  matroskamux name=mux streamable=true \
  ! fdsink \
  | ffmpeg \
    -i pipe:0 \
    -f matroska -live true \
    -vf tmedian=radius=1,hqdn3d \
    -c:v libsvtav1 -svtav1-params pred-struct=1 -crf 20 -maxrate 4m -g $((5 * FRAMERATE)) -keyint_min $((5 * FRAMERATE)) -preset 7 \
    -c:a libopus -b:a 32k -application lowdelay -vbr on \
    pipe:1 \
  | srt-live-transmit -c 1128 file://con srt://:7001/?latency=500

I had to mux in matroska because AV1 cannot be muxed in MPEG-TS. I had to use AV1 because quality was much better than H264 at a tenth of the bitrate. Pipeline speed is dominated by the video filters, not codec speed.

Framerate is 10fps because it's high enough and gives more light and less noise. I may solder more IR LEDs later on (and wire in more power).

Video is downscaled to save on bandwidth and processing power.

Bandwidth is low: around 120kbps at most. Audio plays a big role in the end.

#Configuration

#/boot/config.txt

# dtparam=i2c_arm=on
# dtparam=i2s=on
# dtparam=audio=on
dtoverlay=iqaudio-codec

#Gstreamer packages

apt install gstreamer1.0-alsa gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plug ins-ugly gstreamer1.0-tools

#Updates

#Reports

#Notes