Skip to content

Instantly share code, notes, and snippets.

@nomi-san
Last active November 6, 2024 08:18
Show Gist options
  • Save nomi-san/3c561af3ed4c5c313e75e1031d2b4ec7 to your computer and use it in GitHub Desktop.
Save nomi-san/3c561af3ed4c5c313e75e1031d2b4ec7 to your computer and use it in GitHub Desktop.
Building H264+HEVC decoder FFmpeg (Windows)

Building H264+HEVC decoder FFmpeg (Windows)

1. Setup MSYS2

  • Download MSYS2
  • Install into C:/msys64
  • Edit C:/msys64/msys2_shell.cmd and remove rem from the line with rem MSYS2_PATH_TYPE=inherit
  • Open a x64 Native Tools Command Prompt for VS 2022
  • Run C:/msys64/msys2_shell.cmd
  • Use the MSYS2 shell for the next steps and enter:
pacman -Syu
pacman -S make pkgconf diffutils yasm nasm
 
mv /usr/bin/link.exe /usr/bin/link.exe.bak

2. Clone FFmpeg source

Default version is FFmpeg 6.1.

git clone https://github.com/FFmpeg/FFmpeg.git -b release/6.1 --depth 1
cd ffmpeg

3. Configure build

Config with only decoder H264 & HEVC, dynamic linking.

export CC=cl

./configure \
   --toolchain=msvc \
   --arch=x86_64 \
   --disable-everything \
   --enable-yasm  \
   --enable-asm \
   --enable-shared \
   --disable-static \
   --disable-programs \
   --enable-avresample \
   --enable-decoder=h264 \
   --enable-decoder=hevc \
   --enable-gpl

4. Build FFmpeg

make V=1 -j 8
# make install

The output is too small, under 10MB.
Copy main DLLs from libavcodec/avcodec-60.dll, libavutil/avutil-58.dll.

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