Skip to content

Commit

Permalink
WIP - Attempt to add av1 support
Browse files Browse the repository at this point in the history
For some reason Chrome doesn't detect the codec despite definitely
supporting AV1 decoding.  Nothing telling show up in console,
chrome://webrtc-internals/, or chrome://media-internals/.  Testing
via `docker-compose up`.
  • Loading branch information
Dishwasha committed Jan 15, 2023
1 parent cd9ac70 commit fe6b9ea
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .docker/base/0001-Fix-MIME-type.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From d84ef27b1b2ec2769aa2805bcc54f5601a4ba59a Mon Sep 17 00:00:00 2001
From: Ethan Waldo <[email protected]>
Date: Sat, 7 Jan 2023 17:45:27 -0500
Subject: [PATCH] Fix MIME type

---
gstreamer-plugin/gstsvtav1enc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gstreamer-plugin/gstsvtav1enc.c b/gstreamer-plugin/gstsvtav1enc.c
index 108824c1..86ee29da 100644
--- a/gstreamer-plugin/gstsvtav1enc.c
+++ b/gstreamer-plugin/gstsvtav1enc.c
@@ -129,7 +129,7 @@ static GstStaticPadTemplate gst_svtav1enc_src_pad_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("video/x-av1, "
+ GST_STATIC_CAPS ("video/AV1, "
"stream-format = (string) byte-stream, "
"alignment = (string) au, "
"width = (int) [64, 3840], "
--
2.20.1

25 changes: 22 additions & 3 deletions .docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
FROM golang:1.18-bullseye as server
WORKDIR /src

COPY .docker/base/0001-Fix-MIME-type.patch .
#
# install dependencies
RUN set -eux; apt-get update; \
apt-get install -y --no-install-recommends git cmake make libx11-dev libxrandr-dev libxtst-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly; \
apt-get install -y --no-install-recommends git cmake make libx11-dev libxrandr-dev libxtst-dev python3-pip pkg-config yasm \
gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly; \
#
# install libclipboard
set -eux; \
Expand All @@ -18,8 +19,22 @@ RUN set -eux; apt-get update; \
cmake .; \
make -j4; \
make install; \
cd /tmp; \
rm -rf /tmp/libclipboard; \
#
# install libgstsvtav1enc.so
pip3 install meson ninja; \
git clone --depth=1 --branch v1.4.1 https://gitlab.com/AOMediaCodec/SVT-AV1.git; \
git config --global user.email "[email protected]"; \
git config --global user.name "Your Name"; \
git -C SVT-AV1 am /src/0001-Fix-MIME-type.patch; \
SVT-AV1/Build/linux/build.sh debug; \
cp /tmp/SVT-AV1/Source/API/Eb*.h /usr/local/include; \
cmake -P SVT-AV1/Build/linux/Debug/Source/Lib/Encoder/cmake_install.cmake; \
cd SVT-AV1/gstreamer-plugin; \
meson -Dprefix=/usr build; \
ninja -C build install; \
#
# clean up
apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
Expand Down Expand Up @@ -79,7 +94,7 @@ RUN set -eux; \
# gst + vaapi plugin
apt-get install -y --no-install-recommends libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio \
gstreamer1.0-vaapi ;\
gstreamer1.0-vaapi gstreamer1.0-tools;\
#
# install fonts
apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -136,6 +151,10 @@ ENV RENDER_GID=
#
# copy static files from previous stages
COPY --from=server /src/bin/neko /usr/bin/neko
COPY --from=server /usr/local/lib/libSvtAv1Enc.so.1.4.1 /usr/lib/x86_64-linux-gnu/libSvtAv1Enc.so.1.4.1
COPY --from=server /usr/local/lib/libSvtAv1Enc.so.1 /usr/lib/x86_64-linux-gnu/libSvtAv1Enc.so.1
COPY --from=server /usr/lib/gstreamer-1.0/libgstsvtav1enc.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstsvtav1enc.so

COPY --from=client /src/dist/ /var/www

HEALTHCHECK --interval=10s --timeout=5s --retries=8 \
Expand Down
2 changes: 1 addition & 1 deletion .docker/chromium/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM $BASE_IMAGE
RUN set -eux; \
echo "deb http://ftp.de.debian.org/debian bookworm main" >> /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends unzip chromium chromium-common chromium-sandbox openbox; \
apt-get install -y --no-install-recommends unzip chromium chromium-common chromium-sandbox openbox svt-av1; \
#
# install widevine module
CHROMIUM_DIR="/usr/lib/chromium"; \
Expand Down
11 changes: 10 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ services:
ports:
- "8080:8080"
- "52000-52100:52000-52100/udp"
cap_add:
- ALL
environment:
NEKO_BIND: :8080
NEKO_SCREEN: 1920x1080@30
NEKO_MAX_FPS: 30
#NEKO_AV1: "true"
NEKO_VIDEO_CODEC: av1
NEKO_VIDEO_BITRATE: 1000
NEKO_VIDEO: ximagesrc display-name=%s show-pointer=true use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! svtav1enc
NEKO_PASSWORD: neko
NEKO_PASSWORD_ADMIN: admin
NEKO_EPR: 52000-52100
NEKO_ICELITE: 1
NEKO_ICELITE: "true"
GST_DEBUG: 3
2 changes: 2 additions & 0 deletions docs/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ nat1to1: <ip>
### Video

#### `NEKO_VIDEO_CODEC`:
- av1 *(best option)*
- vp8 *(default encoder)*
- vp9 *(parameter not optimized yet)*
- h264 *(second best option)*
Expand Down Expand Up @@ -161,6 +162,7 @@ Flags:
--audio string audio codec parameters to use for streaming
--audio_bitrate int audio bitrate in kbit/s (default 128)
--audio_codec string audio codec to be used (default "opus")
--av1 DEPRECATED: use video_codec
--bind string address/port/socket to serve neko (default "127.0.0.1:8080")
--broadcast_pipeline string custom gst pipeline used for broadcasting, strings {url} {device} {display} will be replaced
--broadcast_url string URL for broadcasting, setting this value will automatically enable broadcasting
Expand Down
22 changes: 11 additions & 11 deletions server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ require (
github.com/go-chi/cors v1.2.1
github.com/gorilla/websocket v1.5.0
github.com/kataras/go-events v0.0.3
github.com/pion/ice/v2 v2.2.11 // indirect
github.com/pion/ice/v2 v2.2.13 // indirect
github.com/pion/interceptor v0.1.12
github.com/pion/logging v0.2.2
github.com/pion/rtp v1.7.13 // indirect
github.com/pion/srtp/v2 v2.0.10 // indirect
github.com/pion/webrtc/v3 v3.1.47
github.com/pion/srtp/v2 v2.0.11 // indirect
github.com/pion/webrtc/v3 v3.1.50
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.28.0
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.6.0
github.com/spf13/viper v1.13.0
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

Expand All @@ -37,16 +37,16 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pion/datachannel v1.5.2 // indirect
github.com/pion/datachannel v1.5.5 // indirect
github.com/pion/dtls/v2 v2.1.5 // indirect
github.com/pion/mdns v0.0.5 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtcp v1.2.10 // indirect
github.com/pion/sctp v1.8.3 // indirect
github.com/pion/sctp v1.8.5 // indirect
github.com/pion/sdp/v3 v3.0.6 // indirect
github.com/pion/stun v0.3.5 // indirect
github.com/pion/transport v0.13.1 // indirect
github.com/pion/turn/v2 v2.0.8 // indirect
github.com/pion/transport v0.14.1 // indirect
github.com/pion/turn/v2 v2.0.9 // indirect
github.com/pion/udp v0.1.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
Loading

0 comments on commit fe6b9ea

Please sign in to comment.