Skip to content

Commit fe6b9ea

Browse files
committed
WIP - Attempt to add av1 support
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`.
1 parent cd9ac70 commit fe6b9ea

File tree

10 files changed

+152
-18
lines changed

10 files changed

+152
-18
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From d84ef27b1b2ec2769aa2805bcc54f5601a4ba59a Mon Sep 17 00:00:00 2001
2+
From: Ethan Waldo <[email protected]>
3+
Date: Sat, 7 Jan 2023 17:45:27 -0500
4+
Subject: [PATCH] Fix MIME type
5+
6+
---
7+
gstreamer-plugin/gstsvtav1enc.c | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/gstreamer-plugin/gstsvtav1enc.c b/gstreamer-plugin/gstsvtav1enc.c
11+
index 108824c1..86ee29da 100644
12+
--- a/gstreamer-plugin/gstsvtav1enc.c
13+
+++ b/gstreamer-plugin/gstsvtav1enc.c
14+
@@ -129,7 +129,7 @@ static GstStaticPadTemplate gst_svtav1enc_src_pad_template =
15+
GST_STATIC_PAD_TEMPLATE ("src",
16+
GST_PAD_SRC,
17+
GST_PAD_ALWAYS,
18+
- GST_STATIC_CAPS ("video/x-av1, "
19+
+ GST_STATIC_CAPS ("video/AV1, "
20+
"stream-format = (string) byte-stream, "
21+
"alignment = (string) au, "
22+
"width = (int) [64, 3840], "
23+
--
24+
2.20.1
25+

.docker/base/Dockerfile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
FROM golang:1.18-bullseye as server
55
WORKDIR /src
66

7+
COPY .docker/base/0001-Fix-MIME-type.patch .
78
#
89
# install dependencies
910
RUN set -eux; apt-get update; \
10-
apt-get install -y --no-install-recommends git cmake make libx11-dev libxrandr-dev libxtst-dev \
11-
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly; \
11+
apt-get install -y --no-install-recommends git cmake make libx11-dev libxrandr-dev libxtst-dev python3-pip pkg-config yasm \
12+
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; \
1213
#
1314
# install libclipboard
1415
set -eux; \
@@ -18,8 +19,22 @@ RUN set -eux; apt-get update; \
1819
cmake .; \
1920
make -j4; \
2021
make install; \
22+
cd /tmp; \
2123
rm -rf /tmp/libclipboard; \
2224
#
25+
# install libgstsvtav1enc.so
26+
pip3 install meson ninja; \
27+
git clone --depth=1 --branch v1.4.1 https://gitlab.com/AOMediaCodec/SVT-AV1.git; \
28+
git config --global user.email "[email protected]"; \
29+
git config --global user.name "Your Name"; \
30+
git -C SVT-AV1 am /src/0001-Fix-MIME-type.patch; \
31+
SVT-AV1/Build/linux/build.sh debug; \
32+
cp /tmp/SVT-AV1/Source/API/Eb*.h /usr/local/include; \
33+
cmake -P SVT-AV1/Build/linux/Debug/Source/Lib/Encoder/cmake_install.cmake; \
34+
cd SVT-AV1/gstreamer-plugin; \
35+
meson -Dprefix=/usr build; \
36+
ninja -C build install; \
37+
#
2338
# clean up
2439
apt-get clean -y; \
2540
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
@@ -79,7 +94,7 @@ RUN set -eux; \
7994
# gst + vaapi plugin
8095
apt-get install -y --no-install-recommends libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
8196
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio \
82-
gstreamer1.0-vaapi ;\
97+
gstreamer1.0-vaapi gstreamer1.0-tools;\
8398
#
8499
# install fonts
85100
apt-get install -y --no-install-recommends \
@@ -136,6 +151,10 @@ ENV RENDER_GID=
136151
#
137152
# copy static files from previous stages
138153
COPY --from=server /src/bin/neko /usr/bin/neko
154+
COPY --from=server /usr/local/lib/libSvtAv1Enc.so.1.4.1 /usr/lib/x86_64-linux-gnu/libSvtAv1Enc.so.1.4.1
155+
COPY --from=server /usr/local/lib/libSvtAv1Enc.so.1 /usr/lib/x86_64-linux-gnu/libSvtAv1Enc.so.1
156+
COPY --from=server /usr/lib/gstreamer-1.0/libgstsvtav1enc.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstsvtav1enc.so
157+
139158
COPY --from=client /src/dist/ /var/www
140159

141160
HEALTHCHECK --interval=10s --timeout=5s --retries=8 \

.docker/chromium/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM $BASE_IMAGE
66
RUN set -eux; \
77
echo "deb http://ftp.de.debian.org/debian bookworm main" >> /etc/apt/sources.list; \
88
apt-get update; \
9-
apt-get install -y --no-install-recommends unzip chromium chromium-common chromium-sandbox openbox; \
9+
apt-get install -y --no-install-recommends unzip chromium chromium-common chromium-sandbox openbox svt-av1; \
1010
#
1111
# install widevine module
1212
CHROMIUM_DIR="/usr/lib/chromium"; \

docker-compose.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ services:
77
ports:
88
- "8080:8080"
99
- "52000-52100:52000-52100/udp"
10+
cap_add:
11+
- ALL
1012
environment:
13+
NEKO_BIND: :8080
1114
NEKO_SCREEN: 1920x1080@30
15+
NEKO_MAX_FPS: 30
16+
#NEKO_AV1: "true"
17+
NEKO_VIDEO_CODEC: av1
18+
NEKO_VIDEO_BITRATE: 1000
19+
NEKO_VIDEO: ximagesrc display-name=%s show-pointer=true use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! svtav1enc
1220
NEKO_PASSWORD: neko
1321
NEKO_PASSWORD_ADMIN: admin
1422
NEKO_EPR: 52000-52100
15-
NEKO_ICELITE: 1
23+
NEKO_ICELITE: "true"
24+
GST_DEBUG: 3

docs/getting-started/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ nat1to1: <ip>
6666
### Video
6767

6868
#### `NEKO_VIDEO_CODEC`:
69+
- av1 *(best option)*
6970
- vp8 *(default encoder)*
7071
- vp9 *(parameter not optimized yet)*
7172
- h264 *(second best option)*
@@ -161,6 +162,7 @@ Flags:
161162
--audio string audio codec parameters to use for streaming
162163
--audio_bitrate int audio bitrate in kbit/s (default 128)
163164
--audio_codec string audio codec to be used (default "opus")
165+
--av1 DEPRECATED: use video_codec
164166
--bind string address/port/socket to serve neko (default "127.0.0.1:8080")
165167
--broadcast_pipeline string custom gst pipeline used for broadcasting, strings {url} {device} {display} will be replaced
166168
--broadcast_url string URL for broadcasting, setting this value will automatically enable broadcasting

server/go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ require (
88
github.com/go-chi/cors v1.2.1
99
github.com/gorilla/websocket v1.5.0
1010
github.com/kataras/go-events v0.0.3
11-
github.com/pion/ice/v2 v2.2.11 // indirect
11+
github.com/pion/ice/v2 v2.2.13 // indirect
1212
github.com/pion/interceptor v0.1.12
1313
github.com/pion/logging v0.2.2
1414
github.com/pion/rtp v1.7.13 // indirect
15-
github.com/pion/srtp/v2 v2.0.10 // indirect
16-
github.com/pion/webrtc/v3 v3.1.47
15+
github.com/pion/srtp/v2 v2.0.11 // indirect
16+
github.com/pion/webrtc/v3 v3.1.50
1717
github.com/pkg/errors v0.9.1
1818
github.com/rs/zerolog v1.28.0
1919
github.com/spf13/cast v1.5.0 // indirect
2020
github.com/spf13/cobra v1.6.0
2121
github.com/spf13/viper v1.13.0
22-
golang.org/x/crypto v0.1.0 // indirect
23-
golang.org/x/net v0.1.0 // indirect
24-
golang.org/x/sys v0.1.0 // indirect
25-
golang.org/x/text v0.4.0 // indirect
22+
golang.org/x/crypto v0.5.0 // indirect
23+
golang.org/x/net v0.5.0 // indirect
24+
golang.org/x/sys v0.4.0 // indirect
25+
golang.org/x/text v0.6.0 // indirect
2626
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
2727
)
2828

@@ -37,16 +37,16 @@ require (
3737
github.com/mitchellh/mapstructure v1.5.0 // indirect
3838
github.com/pelletier/go-toml v1.9.5 // indirect
3939
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
40-
github.com/pion/datachannel v1.5.2 // indirect
40+
github.com/pion/datachannel v1.5.5 // indirect
4141
github.com/pion/dtls/v2 v2.1.5 // indirect
4242
github.com/pion/mdns v0.0.5 // indirect
4343
github.com/pion/randutil v0.1.0 // indirect
4444
github.com/pion/rtcp v1.2.10 // indirect
45-
github.com/pion/sctp v1.8.3 // indirect
45+
github.com/pion/sctp v1.8.5 // indirect
4646
github.com/pion/sdp/v3 v3.0.6 // indirect
4747
github.com/pion/stun v0.3.5 // indirect
48-
github.com/pion/transport v0.13.1 // indirect
49-
github.com/pion/turn/v2 v2.0.8 // indirect
48+
github.com/pion/transport v0.14.1 // indirect
49+
github.com/pion/turn/v2 v2.0.9 // indirect
5050
github.com/pion/udp v0.1.1 // indirect
5151
github.com/spf13/afero v1.9.2 // indirect
5252
github.com/spf13/jwalterweatherman v1.1.0 // indirect

0 commit comments

Comments
 (0)