Hi,
I’m trying to create a pipeline that encodes an AV1 HLS video and it creates a huge single segment without a playlist. It is working the same way even with a test source: gst-launch-1.0 videotestsrc is-live=true ! nvvidconv ! "video/x-raw(memory:NVMM), width=(int)640, height=(int)480, framerate=30/1" ! nvv4l2av1enc ! matroskamux ! hlssink max-files=5 location="/dev/shm/river/video/stream%03d.ts" target-duration=5 max-files=5 playlist-root="/dev/shm/river/video" playlist-location="/dev/shm/river/video/playlist.m3u8"
I’ve found no examples of GStreamer AV1 HLS. Am I doing it wrong?
AV1 with HLS may not be a good choice, because av1parse comes with gstreamer 1.19.
Without this, hlssink may not be able to fragment the stream, so you will have only one ts growing forever. Furthermore, the playlist may not be created.
For experiment, you may try running this pipeline recording for 10s, creating the ts file and creating the playlist (the latter may be actually written at closing time):
I’ve also tried to use multifilesink instead of hlssink and having a script for creating/updating the playlist. However, it only works if the first ts (segment_00000.ts) is still there and read first.
My last suggestion for streaming AV1 would be using TCP, but the receiver would have to be started before sender so that the former receives the start of the stream:
Nice idea with multifilesink. I’m currently trying build 1.19 to useavparse. I hope I understood correctly and there is a chance to build v4l2 for this version. At least there is a suitable tag in repository. But the absence of a 1.19 branch does not bode well
Well, I’ve built gstreamer 1.19.2 and 1.22.5, but av1parse doesn’t work with hlssink (and hlssink2 refuses to receive av1).
However, using av1parse allows streaming with TCP and client can connect at any time.
For reference, this is the script I’ve been using. It keeps the original gstreamer unmodified, it installs in user filesystem:
#!/bin/sh
set -x
#VERSION=1.19.2
VERSION=1.22.5
mkdir gst_$VERSION
cd gst_$VERSION
PREFIX=$(pwd)
wget https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-$VERSION.tar.xz --no-check-certificate
wget https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-$VERSION.tar.xz --no-check-certificate
for a in `ls -1 *.tar.*`; do tar -xf $a; done
# install dependancies
sudo apt install -y build-essential dpkg-dev flex bison autotools-dev automake autopoint libtool libgstreamer1.0-dev libxv-dev libasound2-dev libtheora-dev libogg-dev libvorbis-dev libbz2-dev libv4l-dev libvpx-dev libjack-jackd2-dev libsoup2.4-dev libpulse-dev faad libfaad-dev libgl1-mesa-dev libgles2-mesa-dev libx264-dev libmad0-dev gobjc-9 libmount-dev libglib2.0-dev
pip3 install --upgrade meson
# GStreamer framework
cd gstreamer-$VERSION
meson setup -Dprefix=$PREFIX/out build
ninja -C build install
cd ..
# Adjust environment for the new gstreamer framework
export PATH=$PREFIX/out/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/out/lib/aarch64-linux-gnu/:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$PREFIX/out/lib/aarch64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
#Base
cd gst-plugins-base-$VERSION
meson setup -Dprefix=$PREFIX/out build
ninja -C build install
cd ..
#Good
cd gst-plugins-good-$VERSION
meson setup -Dprefix=$PREFIX/out build
ninja -C build install
cd ..
#Bad
cd gst-plugins-bad-$VERSION
meson setup -Dprefix=$PREFIX/out build
ninja -C build install
cd ..
# Ugly
cd gst-plugins-ugly-$VERSION
meson setup -Dprefix=$PREFIX/out build
ninja -C build install
cd ..
# Copy NVIDIA binaries
cp /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnv* $PREFIX/out/lib/aarch64-linux-gnu/gstreamer-1.0/
chmod u+x $PREFIX/out/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnv*
if [ -d /etc/alternatives/deepstream-plugins/ ]; then
ln -s /etc/alternatives/deepstream-plugins/ $PREFIX/out/lib/aarch64-linux-gnu/gstreamer-1.0/deepstream
fi
# First clear gstreamer cache
rm ~/.cache/gstreamer-1.0/registry.aarch64.bin
# add new plugins path
export GST_PLUGIN_PATH=$PREFIX/out/lib/aarch64-linux-gnu/gstreamer-1.0
gst-inspect-1.0 --version
gst-inspect-1.0 -b
For using it, you would set the environment with:
# Adjust to your install path and version
export PREFIX=/home/nvidia/Desktop/gstreamer-1.0/gst_1.22.5
export PATH=$PREFIX/out/bin:$PATH
export LD_LIBRARY_PATH=$PREFIX/out/lib/aarch64-linux-gnu/:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$PREFIX/out/lib/aarch64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
I’m interested in AV1 over HLS to reduce existent trafic.
I’ve tried a ton of different approaches and now I’m sure that GStreamer has no solution for this. At least for now.
Thank you for the script. I think it will be useful to update my setup to a new version anyway.