Videos: Update install-ffmpeg.sh script to install static build #4181

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2024-05-30 09:38:28 +02:00
parent 800279ea61
commit ade16f166b
2 changed files with 49 additions and 25 deletions

View file

@ -1,16 +1,29 @@
#!/usr/bin/env bash
# This installs FFmpeg on Ubuntu Linux.
# This installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-ffmpeg.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
# Show usage information if first argument is --help.
if [[ ${1} == "--help" ]]; then
echo "This installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/." 1>&2
echo "Usage: ${0##*/} [destdir] [version]" 1>&2
exit 0
fi
# Abort if not executed as root.
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
exit 1
fi
# You can provide a custom installation directory as the first argument.
DESTDIR=$(realpath "${1:-/opt/ffmpeg}")
# In addition, you can specify a custom version as the second argument.
FFMPEG_VERSION=${2:-release}
# Determine the system architecture.
if [[ $PHOTOPRISM_ARCH ]]; then
SYSTEM_ARCH=$PHOTOPRISM_ARCH
@ -20,35 +33,44 @@ fi
DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
set -e
. /etc/os-release
case $DESTARCH in
amd64 | AMD64 | x86_64 | x86-64 | arm64 | ARM64 | aarch64)
if [[ $VERSION_CODENAME == "noble" ]]; then
# Install FFmpeg 7 from a PPA on Ubuntu 24.04 LTS.
echo "Installing FFmpeg 7 for ${DESTARCH^^} from ppa:ubuntuhandbook1/ffmpeg7..."
apt-get update
apt-get -qq install software-properties-common pkg-config apt-utils
add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg7
apt-get update
apt-get -qq install ffmpeg
apt-get -qq dist-upgrade
else
# Otherwise, install the default FFmpeg package.
echo "Installing FFmpeg for ${DESTARCH^^}..."
apt-get update
apt-get -qq install ffmpeg
fi
amd64 | AMD64 | x86_64 | x86-64)
DESTARCH=amd64
;;
arm64 | ARM64 | aarch64)
DESTARCH=arm64
;;
arm | ARM | aarch | armv7l | armhf)
DESTARCH=armhf
;;
*)
# Install the default FFmpeg package.
echo "Installing FFmpeg for ${DESTARCH^^}..."
apt-get update
apt-get -qq install ffmpeg
echo "Unsupported Machine Architecture: \"$DESTARCH\"" 1>&2
exit 1
;;
esac
. /etc/os-release
echo "Installing FFmpeg..."
ARCHIVE="ffmpeg-${FFMPEG_VERSION}-${DESTARCH}-static.tar.xz"
URL="https://johnvansickle.com/ffmpeg/releases/${ARCHIVE}"
echo "------------------------------------------------"
echo "VERSION: $FFMPEG_VERSION"
echo "ARCHIVE: $ARCHIVE"
echo "DESTDIR: $DESTDIR"
echo "------------------------------------------------"
echo "Extracting \"$URL\" to \"$DESTDIR\"."
mkdir -p "${DESTDIR}"
wget --inet4-only -c "$URL" -O - | tar --strip-components=1 --overwrite --mode=755 -x --xz -C "$DESTDIR"
chown -R root:root "${DESTDIR}"
# Create a symbolic link to the static ffmpeg binary.
ln -sf "${DESTDIR}/ffmpeg" /usr/local/bin/ffmpeg
echo "Done."

View file

@ -62,6 +62,8 @@ case $VERSION_CODENAME in
;;
esac
echo "Installing libheif..."
ARCHIVE="libheif-${VERSION_CODENAME}-${DESTARCH}-${LIBHEIF_VERSION}.tar.gz"
URL="https://dl.photoprism.app/dist/libheif/${ARCHIVE}"