Av1 hls

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?

Orin NX. GStreamer 1.16

Moved to Jetson Orin NX forum

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):

gst-launch-1.0 -e videotestsrc num-buffers=3000 ! video/x-raw,width=640,height=480,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvv4l2av1enc enable-headers=1 ! queue ! hlssink playlist-root="http://127.0.0.1:8080" location="/home/nvidia/tmp/hls/segment_%05d.ts" max-files=5 target-duration=5 playlist-location="/home/nvidia/tmp/hls/playlist.m3u8"

Then you would run simpleHTTPserver (can be installed from pip):

python -m SimpleHTTPServer 8080 &

and from another terminal you may be able to read with something like:

gst-launch-1.0 souphttpsrc location=http://127.0.0.1:8080/playlist.m3u8 is-live=true do-timestamp=true ! application/x-hls ! hlsdemux ! decodebin ! queue ! nvvidconv ! autovideosink

Someone better skilled may advise a better way for streaming AV1.

Thank you for explanation

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:

Receiver:

gst-launch-1.0 tcpserversrc host=127.0.0.1 ! decodebin ! queue ! nvvidconv ! autovideosink

Sender:

gst-launch-1.0  videotestsrc ! video/x-raw,width=640,height=480,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvv4l2av1enc enable-headers=1 ! queue ! tcpclientsink host=127.0.0.1

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

OMG. I have completely misunderstood the whole thing about building a new version of GStreamer with nVidia plugins. It is quite a task.

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

Then you can stream AV1 over TCP with:

gst-launch-1.0 videotestsrc ! nvvidconv ! nvv4l2av1enc idrinterval=15 ! queue ! av1parse ! tcpserversink host=127.0.0.1

and receive with:

gst-launch-1.0 tcpclientsrc host=127.0.0.1 ! av1parse ! nvv4l2decoder ! queue ! nvvidconv ! autovideosink

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.

The script is mostly untested, but I haven’t faced any issue so far using old nvidia binaries.

I am unsure if hls streaming with AV1 encoding is really possible from Jetson Orin. Someone more skilled may better advise.

I’d suggest to stream from Orin with TCP to a host, then check if you can hls stream from there.
Have fun and share ;-)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.