Building ffmpeg + x264 using Visual Studio 2015

Posted by admin | Posted in Uncategorized | Posted on 29-06-2017-05-2008

0

Today I managed to compile ffmpeg with x264 using Visual Studio 2015.

The page https://pracucci.com/compile-ffmpeg-on-windows-with-visual-studio-compiler.html was the starting point, and I managed to include x264 as well, to play H.264 content.

As a bonus, the generated DLL have SEH enabled, so you don’t need to build your own application with /SAFESEH:NO, which is a great headache.

The differences to compile 32 and 64-bit versions are minimal, so they will be appointed inline.

Step 1: Install MSYS2

Download “MSYS2 x86_64” from http://msys2.github.io and install into “C:\workspace\windows\msys64”.

Open a Visual Studio 2015 development command prompt (“VS2015 x86 Native Tools Command Prompt” or “VS2015 x64 Native Tools Command Prompt”).

  • For 32-bits, execute the command
    C:\workspace\windows\msys64\msys2_shell.cmd -mingw32 -use-full-path
  • For 64-bits, execute the command
    C:\workspace\windows\msys64\msys2_shell.cmd -mingw64 -use-full-path

Inside the MSYS2 shell, install the needed packages:

# pacman -S make gcc diffutils mingw-w64-{i686,x86_64}-pkg-config mingw-w64-i686-nasm mingw-w64-i686-yasm

Rename the MSYS2 “link.exe” so the compilation uses link.exe from VS2015.

# mv /usr/bin/link.exe /usr/bin/link_old.exe

Step 2: Build x264

Clone x264 to the directory you will be compiling on (the HOME directory, for example), build, and install on /usr/local.

# git clone http://git.videolan.org/git/x264.git
# cd x264
# CC=cl ./configure –enable-static –prefix=/usr/local –disable-cli
# make
# make install

Step 3: Build ffmpeg

Download and extract the ffmpeg sources from http://www.ffmpeg.org/download.html.

# cd ffmpeg-3.3.2

Set the pkg-config path so ffmpeg finds the x264 library we built.

# export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

Configure ffmpeg (The ffmpeg programs where giving me compilation errors, so I disabled them):

  • For 32-bits, execute:
    ./configure –toolchain=msvc –arch=x86 –enable-yasm –enable-asm –enable-shared –disable-static –disable-programs –enable-avresample –enable-libx264 –enable-gpl –prefix=./install
  • For 64-bits, execute:
    ./configure –toolchain=msvc –arch=x86_64 –enable-yasm –enable-asm –enable-shared –disable-static –disable-programs –enable-avresample –enable-libx264 –enable-gpl –prefix=./install

# make
# make install

The ffmpeg distribution will be on the “install” diretory.

Here is the 32-bits compiled version.

ffmpeg-libs-3.3.2-vs2015-x86