Created
June 27, 2025 07:18
-
-
Save gustavomdsantos/c91090f0fd93d994a2db7333b3945c5f to your computer and use it in GitHub Desktop.
Custom FFmpeg Makefile - Builds a deb file from "yt-dlp/FFmpeg-Builds" latest release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
TARBALL_URL="https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz" | |
RELEASE_URL="https://github.com/yt-dlp/FFmpeg-Builds/releases/tag/latest" | |
TEMP_DIR="$(mktemp -d)" | |
TARBALL_NAME="ffmpeg.tar.xz" | |
PACKAGE_BASE="yt-dlp-ffmpeg" | |
ARCH="amd64" | |
MAINTAINER="Gustavo Moraes <[email protected]>" | |
DESCRIPTION="Custom static build of FFmpeg from yt-dlp repository." | |
REQUIRED_CMDS=("wget" "curl" "awk" "tar" "mkdir" "cp" "install" "dpkg-deb") | |
error_exit(){ echo "ERROR: $1" >&2; exit 1; } | |
check_deps(){ for c in "${REQUIRED_CMDS[@]}"; do command -v "$c" &>/dev/null || error_exit "Missing: $c"; done; } | |
download_and_extract(){ | |
echo -e "\n>> Downloading FFmpeg...\n" | |
wget --show-progress -O "$TEMP_DIR/$TARBALL_NAME" "$TARBALL_URL" \ | |
|| error_exit "Download failed" | |
echo -e "\n>> Extracting...\n" | |
tar -xf "$TEMP_DIR/$TARBALL_NAME" -C "$TEMP_DIR" \ | |
|| error_exit "Extraction failed" | |
} | |
detect_version() { | |
echo -e "\n>> Detecting version from latest release page...\n" | |
VERSION=$(curl -fsSL "$RELEASE_URL" | \ | |
grep -oP 'Latest Auto-Build \(\K[0-9]{4}-[0-9]{2}-[0-9]{2}(?= [0-9]{2}:[0-9]{2})' | head -n1) | |
if [[ -z "$VERSION" ]]; then | |
error_exit "Failed to detect FFmpeg version from the release page" | |
fi | |
echo "-> Version detected: $VERSION" | |
} | |
prepare(){ | |
PKG_ROOT="$TEMP_DIR/$VERSION" | |
mkdir -p "$PKG_ROOT"/{DEBIAN,usr/bin,usr/share/man/man1,usr/share/man/man3,usr/share/doc/$PACKAGE_BASE} | |
install -m755 "$TEMP_DIR"/ffmpeg-master-*/bin/* "$PKG_ROOT/usr/bin/" | |
install -m644 "$TEMP_DIR"/ffmpeg-master-*/man/man1/* "$PKG_ROOT/usr/share/man/man1/" | |
install -m644 "$TEMP_DIR"/ffmpeg-master-*/man/man3/* "$PKG_ROOT/usr/share/man/man3/" | |
cp -r "$TEMP_DIR"/ffmpeg-master-*/doc/* "$PKG_ROOT/usr/share/doc/$PACKAGE_BASE/" | |
install -m644 "$TEMP_DIR"/ffmpeg-master-*/LICENSE.txt "$PKG_ROOT/usr/share/doc/$PACKAGE_BASE/" | |
} | |
create_control(){ | |
ctrl="$PKG_ROOT/DEBIAN/control" | |
echo -e "\n>> Creating control file...\n" | |
cat > "$ctrl" <<EOF | |
Package: $PACKAGE_BASE | |
Version: $VERSION | |
Section: video | |
Priority: optional | |
Architecture: $ARCH | |
Maintainer: $MAINTAINER | |
Description: $DESCRIPTION | |
EOF | |
chmod 0644 "$ctrl" | |
} | |
build_deb(){ | |
out="${PACKAGE_BASE}_${VERSION}_${ARCH}.deb" | |
echo -e "\n>> Building .deb with ZSTD compression...\n" | |
dpkg-deb --build -Zzstd -z19 --root-owner-group "$PKG_ROOT" "$TEMP_DIR/$out" | |
mv "$TEMP_DIR/$out" "$(pwd)/$out" | |
echo -e "\n>>> Package ready: $(pwd)/$out\n" | |
} | |
cleanup(){ | |
echo -e "\n>> Cleaning temporary files...\n" | |
rm -rf "$TEMP_DIR" | |
} | |
main(){ | |
check_deps | |
detect_version | |
download_and_extract | |
prepare | |
create_control | |
build_deb | |
cleanup | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment