Skip to content

Commit

Permalink
feat: implement support for AMD AMF codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
kode54 committed Jan 17, 2025
1 parent befb906 commit a024caf
Show file tree
Hide file tree
Showing 13 changed files with 3,254 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
!CMakeLists.txt
!.clang-format
!docker/gstreamer.control
!docker/startup.sh
!docker/startup.sh
!docker/gstreamer/
30 changes: 30 additions & 0 deletions docker/gpu-drivers.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ RUN apt-get update -y && \
$REQUIRED_PACKAGES && \
rm -rf /var/lib/apt/lists/*

# Add Advanced Media Framework runtime for AMD
RUN <<_ADD_AMF
#!/bin/bash
set -e

#Extra deps
apt-get update -y
apt-get install -y curl

cd /tmp
curl -fsSLO https://repo.radeon.com/amdgpu/6.3/ubuntu/pool/proprietary/liba/libamdenc-amdgpu-pro/libamdenc-amdgpu-pro_1.0-2079599.24.04_amd64.deb
curl -fsSLO https://repo.radeon.com/amdgpu/6.3/ubuntu/pool/proprietary/a/amf-amdgpu-pro/amf-amdgpu-pro_1.4.36-2079599.24.04_amd64.deb

mkdir out

dpkg-deb -xv libamdenc-amdgpu-pro_1.0-2079599.24.04_amd64.deb ./out

dpkg-deb -xv amf-amdgpu-pro_1.4.36-2079599.24.04_amd64.deb ./out

mkdir -p /opt/amdgpu-pro/lib/x86_64-linux-gnu
mv out/opt/amdgpu-pro/lib/x86_64-linux-gnu/* /opt/amdgpu-pro/lib/x86_64-linux-gnu/

echo "/opt/amdgpu-pro/lib/x86_64-linux-gnu" >> /etc/ld.so.conf.d/amf.conf

# Cleanup
apt-get remove -y --purge curl
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/*.deb /tmp/out
_ADD_AMF

# Adding missing libnvrtc.so and libnvrtc-bulletins.so for Nvidia
# https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvrtc/LICENSE.txt
RUN <<_ADD_NVRTC
Expand Down
8 changes: 7 additions & 1 deletion docker/gstreamer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Provides: gstreamer, libgstreamer1.0-0
Description: Manually built from git
EOT

COPY docker/gstreamer/*.patch $SOURCE_PATH/

RUN <<_GSTREAMER_INSTALL
#!/bin/bash
set -e
Expand All @@ -39,7 +41,7 @@ RUN <<_GSTREAMER_INSTALL
libmfx-dev libvpl-dev libmfx-tools libunwind8 libcap2-bin \
libx11-dev libxfixes-dev libxdamage-dev libwayland-dev libpulse-dev libglib2.0-dev \
libopenjp2-7-dev liblcms2-dev libcairo2-dev libcairo-gobject2 libwebp7 librsvg2-dev libaom-dev \
libharfbuzz-dev libpango1.0-dev
libharfbuzz-dev libpango1.0-dev libudev-dev curl
"
apt-get update -y
apt-get install -y --no-install-recommends $DEV_PACKAGES
Expand All @@ -48,6 +50,9 @@ RUN <<_GSTREAMER_INSTALL
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git $SOURCE_PATH/gstreamer
cd ${SOURCE_PATH}/gstreamer
git checkout $GSTREAMER_SHA_COMMIT
patch -Np1 -i $SOURCE_PATH/gst-amf-headers.patch
patch -Np1 -i $SOURCE_PATH/gst-amf-av1-usage.patch
patch -Np1 -i $SOURCE_PATH/gst-amf-linux.patch
git submodule update --recursive --remote
# see the list of possible options here: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/meson_options.txt \
meson setup \
Expand Down Expand Up @@ -77,6 +82,7 @@ RUN <<_GSTREAMER_INSTALL
-Dgst-plugins-bad:qsv=enabled \
-Dgst-plugins-bad:aom=enabled \
-Dgst-plugin-bad:nvcodec=enabled \
-Dgst-plugins-bad:amfcodec=enabled \
-Dvaapi=enabled \
build
meson compile -C build
Expand Down
31 changes: 31 additions & 0 deletions docker/gstreamer/gst-amf-av1-usage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/subprojects/gst-plugins-bad/sys/amfcodec/gstamfav1enc.cpp b/subprojects/gst-plugins-bad/sys/amfcodec/gstamfav1enc.cpp
index 6280cc05e7..482c1f7f98 100644
--- a/subprojects/gst-plugins-bad/sys/amfcodec/gstamfav1enc.cpp
+++ b/subprojects/gst-plugins-bad/sys/amfcodec/gstamfav1enc.cpp
@@ -98,12 +98,26 @@ gst_amf_av1_enc_usage_get_type (void)
*/
{AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING, "Transcoding", "transcoding"},

+ /**
+ * GstAmfAv1EncUsage::ultra-low-latency:
+ *
+ * Ultra Low Latency usage
+ */
+ {AMF_VIDEO_ENCODER_AV1_USAGE_ULTRA_LOW_LATENCY, "Ultra Low Latency", "ultra-low-latency"},
+
/**
* GstAmfAv1EncUsage::low-latency:
*
* Low Latency usage
*/
{AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY, "Low Latency", "low-latency"},
+
+ /**
+ * GstAmfAv1EncUsage::webcam:
+ *
+ * Webcam usage
+ */
+ {AMF_VIDEO_ENCODER_AV1_USAGE_WEBCAM, "Webcam", "webcam"},
{0, nullptr, nullptr}
};

2,299 changes: 2,299 additions & 0 deletions docker/gstreamer/gst-amf-headers.patch

Large diffs are not rendered by default.

Loading

0 comments on commit a024caf

Please sign in to comment.