Skip to content

Instantly share code, notes, and snippets.

@thewh1teagle
Last active January 9, 2024 22:27
Show Gist options
  • Select an option

  • Save thewh1teagle/7d1a7f8164ac52b7ad041962f0a9cbf8 to your computer and use it in GitHub Desktop.

Select an option

Save thewh1teagle/7d1a7f8164ac52b7ad041962f0a9cbf8 to your computer and use it in GitHub Desktop.
static link ffmpeg
# Download msys2 from https://www.msys2.org/ and open ucrt64 terminal
TARGET=$(pwd)/rust-ffmpeg1
REPO=https://github.com/zmwangx/rust-ffmpeg
FFMPEG_NAME=ffmpeg-n6.1-latest-win64-gpl-shared-6.1
FFMPEG_SRC_PREFIX=latest
FFMPEG_SRC=https://github.com/BtbN/FFmpeg-Builds/releases/download/$FFMPEG_SRC_PREFIX/$FFMPEG_NAME.zip

git clone $REPO $TARGET
if [ ! -d $TARGET/$FFMPEG_NAME ]; then
    wget -q --show-progress $FFMPEG_SRC -O $TARGET/$FFMPEG_NAME.zip
    unzip $TARGET/$FFMPEG_NAME.zip -d $TARGET
    rm $TARGET/$FFMPEG_NAME.zip
fi

export FFMPEG_DIR="$TARGET/$FFMPEG_NAME"
# rename .dll.a to .a so it will link it
for file in $FFMPEG_DIR/lib/*.dll.a; do mv "$file" "${file%.dll.a}.a"; done
echo "\$FFMPEG_DIR is $FFMPEG_DIR"
cd $TARGET
rustup override set stable-x86_64-pc-windows-gnu # very important!!
cargo build --release --example transcode-audio
$TARGET/target/release/examples/transcode-audio.exe
ldd $TARGET/target/release/examples/transcode-audio.exe # check dependencies

CARGO_FEATURE_STATIC=yes cargo build --release -vv 2>&1 | grep "avutil"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment