-
-
Save roxlu/e75a4db2cb2c40c9f6c897c38e7f053a to your computer and use it in GitHub Desktop.
Build FFMPEG with X264
This file contains 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
#!/bin/sh | |
# | |
# Blog post: | |
# | |
# - https://www.roxlu.com/2019/061/compiling-ffmpeg-with-x264-on-windows-10-using-msvc | |
# | |
# From: | |
# - https://gist.github.com/roxlu/e75a4db2cb2c40c9f6c897c38e7f053a | |
# | |
# References: | |
# | |
# - https://gist.github.com/RangelReale/3e6392289d8ba1a52b6e70cdd7e10282 | |
# - https://feru007.blogspot.com/?view=classic | |
# | |
d=${PWD} | |
source_dir=${d}/sources | |
build_dir=${d}/build | |
install_dir=${d}/installed | |
if [ ! -d ${source_dir} ] ; then | |
mkdir ${source_dir} | |
fi | |
if [ ! -d ${build_dir} ] ; then | |
mkdir ${build_dir} | |
fi | |
# Download sources | |
# --------------------------------------------------- | |
cd ${source_dir} | |
if [ ! -d ffmpeg ] ; then | |
git clone --depth 1 git://source.ffmpeg.org/ffmpeg.git | |
fi | |
if [ ! -d x264 ] ; then | |
git clone https://code.videolan.org/videolan/x264.git | |
fi | |
# Build dependencies | |
# --------------------------------------------------- | |
cd ${build_dir} | |
if [ ! -d x264 ] ; then | |
mkdir ${build_dir}/x264 | |
cd x264 | |
# make sure msys2 is recognized | |
curl "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD" > config.guess | |
sed -i 's/host_os = mingw/host_os = msys/' configure | |
CC=cl ${source_dir}/x264/configure --prefix=${install_dir} --enable-shared | |
make -j 8 | |
make install | |
mv ${install_dir}/lib/libx264.dll.lib ${install_dir}/lib/libx264.lib | |
fi | |
# Build FFMPEG | |
# --------------------------------------------------- | |
cd ${build_dir} | |
if [ ! -d ffmpeg ] ; then | |
export CC=cl | |
mkdir ${build_dir}/ffmpeg | |
cd ffmpeg | |
${source_dir}/ffmpeg/configure \ | |
--prefix=${install_dir} \ | |
--toolchain=msvc \ | |
--arch=x86_64 \ | |
--enable-yasm \ | |
--enable-asm \ | |
--enable-shared \ | |
--disable-static \ | |
--disable-programs \ | |
--enable-avresample \ | |
--enable-libx264 \ | |
--enable-gpl \ | |
--extra-ldflags="-LIBPATH:${install_dir}/lib/" \ | |
--extra-cflags="-I${install_dir}/include/" | |
make V=1 -j 8 | |
make install | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment