Skip to content

Instantly share code, notes, and snippets.

@jeeb
Created December 3, 2010 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeeb/726410 to your computer and use it in GitHub Desktop.
Save jeeb/726410 to your computer and use it in GitHub Desktop.
Herp derp x264 build script
#!/bin/sh
# Some kind of buildscript for x264
# The stuff I used the last time:
# * CCCP's Nicholi's April 2010 msys/mingw package
# * Newest 7z file with the Msys/Mingw from xhmikosr found at:
# http://sourceforge.net/apps/trac/mpc-hc/wiki/How_to_compile_the_MPC
# * Your favourite mingw package (Komisar's or Alexis', both are fine)
# * Command-line SVN
# http://subversion.tigris.org/files/documents/15/47914/svn-win32-1.6.6.zip
#
# 01) Extract Nicholi's package somewhere where the path doesn't have spaces in it.
# 02) Extract xhmikosr's msys/mingw package so that it goes over nicholi's (the bin
# etc. folders in the msys/1.0 folder), but NOT the files within the msys/1.0
# folder such a the .bat etc. This keeps the lovely rxvt shell, which, albeit
# failing unicode, is pretty nice otherwise.
# 03) Extract your mingw package into the msys root folder that has the 1.0 folder within it.
# 04) Extract the svn package's bin etc. folders (inside the svn-xxx folder) into komisar's mingw's root.
# 05) Edit msys/1.0/etc/fstab with something like notepad++ that can actually edit *nix endlines.
# 06) Edit the mingw and perl lines to point at the correct places (/mingw needs to point to komisar's mingw root).
# Yes, you will use / not \.
# 0X) You will need one pkg-config.exe for each of your 64bit "archs".
# I just made new copies of my pkg-config.exe in msys/1.0/bin by the name x86_64-pc-mingw32-pkg-config.exe
# and x86_64-w64-mingw32-pkg-config.exe.
# 07) Run the bat file in msys/1.0.
# 08) Get golgol's gpac and build it as told in the end of the script.
# 09) Get ffmpeg, libswscale as per http://www.ffmpeg.org/download.html (git used here)
# 10) Get ffmpegsource.
# 11) make the folder structure of builds/32,64
# 12) Make sure the two patches in the patched version work with the current revision.
# If they don't, just comment out the line(s) that applie(s) them.
# 13) Run the script. Add 64bit prefix for 64bit builds.
P64B=`ls /mingw |grep x86_64`
echo Gotten prefix: ${P64B}
echo ""
# Uncomment if you can has no LAME yet
# LAME 3.9.8.4
# cd lame-3.98.4
# 32bit
# make distclean
# PKG_CONFIG_PATH=/mingw/i686-pc-mingw32/lib/pkgconfig/ ./configure --prefix=/mingw/i686-pc-mingw32 --disable-shared
# make
# make install
# 64bit
# make distclean
# PKG_CONFIG_PATH=/mingw/${P64B}/lib/pkgconfig/ ./configure --host=${P64B} --prefix=/mingw/${P64B} --disable-shared
# make
# make install
# cd ..
# Uncomment if you can has no libopencore-amr
# libopencore-amr from git
# git clone git://opencore-amr.git.sourceforge.net/gitroot/opencore-amr/opencore-amr opencore-amr
# cd opencore-amr
# 32bit
# make distclean
# PKG_CONFIG_PATH=/mingw/i686-pc-mingw32/lib/pkgconfig/ ./configure --prefix=/mingw/i686-pc-mingw32 --disable-shared
# make
# make install
# 64bit
# make distclean
# PKG_CONFIG_PATH=/mingw/${P64B}/lib/pkgconfig/ ./configure --host=${P64B} --prefix=/mingw/${P64B} --disable-shared
# make
# make install
# cd ..
# Remove old folders.
rm -rf x264-pure
rm -rf x264-patched
# Build ffmpeg
# cd ffmpeg
# make distclean
# git pull
# git rev-list HEAD | wc -l | sed -e 's/^ *//' > ../builds/pure/ffmpegrev64bit.txt
# cd libswscale
# git pull
# git rev-list HEAD | wc -l | sed -e 's/^ *//' > ../../builds/pure/ffmpeglibswscalerev64bit.txt
# cd ..
# 32bit
# ./configure --prefix=/mingw/i686-pc-mingw32 --enable-gpl --enable-postproc --enable-filters --disable-network --enable-memalign-hack --extra-cflags='-U__STRICT_ANSI__' --enable-runtime-cpudetect --enable-pthreads --extra-cflags='-DPTW32_STATIC_LIB' --disable-hwaccels --enable-libmp3lame --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb
# make -j2
# make install
# make distclean
# 64bit
# ./configure --prefix=/mingw/${P64B} --cross-prefix=${P64B}- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-postproc --enable-filters --disable-network --extra-cflags='-U__STRICT_ANSI__' --enable-runtime-cpudetect --enable-pthreads --extra-cflags='-DPTW32_STATIC_LIB' --disable-hwaccels --enable-libmp3lame --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb
# make -j2
# make install
# cd ..
# Build ffmpegsource
# cd ffmpegsource
# make distclean
# svn up
# svn info | grep Revision > ../builds/pure/ffmpegsourcerev64bit.txt
# 32bit
# PKG_CONFIG_PATH=/mingw/i686-pc-mingw32/lib/pkgconfig/ ./configure --prefix=/mingw/i686-pc-mingw32
# make
# make install
# make distclean
# 64bit
# PKG_CONFIG_PATH=/mingw/${P64B}/lib/pkgconfig/ ./configure --host=${P64B} --prefix=/mingw/${P64B}
# make
# make install
# cd ..
# Update sources of x264 and x264_L-SMASH
cd x264
git pull
cd ..
cd x264_L-SMASH
git pull
git fetch porigin
cd ..
cp -r x264_L-SMASH x264-patched
# cp -r x264 x264-pure
# Pure x264 64bit
# cd x264-pure
# PKG_CONFIG_PATH=/mingw/${P64B}/lib/pkgconfig/ ./configure --cross-prefix=${P64B}- --host=${P64B} --extra-ldflags=-lavcore
# make fprofiled VIDS="../zeroma.y4m ../foreman_cif.y4m"
# md5sum x264.exe | awk '{print $1}' >x264.md5
# cp x264.exe ../builds/pure
# cp x264.md5 ../builds/pure
# cd ..
# Patched x264
cd x264-patched
# Patchan and committan
echo Patching! > ../patching_log.txt
echo Filters fixes >> ../patching_log.txt
git apply ../patches/00-yet_another_resize_patch.patch 2>> ../patching_log.txt
git add .
git commit -am "Resize fix nr.99"
echo Extra filters >> ../patching_log.txt
git apply ../patches/01-Old-extra-video-filter-patch-20101127.patch 2>> ../patching_log.txt
git add .
git commit -a -m "Adding extra filters, f.ex. YADIF."
echo FGO >> ../patching_log.txt
git apply ../patches/02_x264_film_grain_optimization_20101128.patch 2>> ../patching_log.txt
git add .
git commit -am "FGO"
echo FadeComp >> ../patching_log.txt
git apply ../patches/03_x264_fadecomp_20101128.patch 2>> ../patching_log.txt
git add .
git commit -am "FadeComp"
# 32bit
PKG_CONFIG_PATH=/mingw/i686-pc-mingw32/lib/pkgconfig/ ./configure --qtsdk=/qtsdk
make fprofiled VIDS="../zeroma.y4m ../foreman_cif.y4m"
cp x264.exe ../builds/32
cp libx264.a ../builds/32
# make distclean
# 64bit
PKG_CONFIG_PATH=/mingw/${P64B}/lib/pkgconfig/ ./configure --cross-prefix=${P64B}- --host=${P64B} --qtsdk=/qtsdk
make fprofiled VIDS="../zeroma.y4m ../foreman_cif.y4m"
cp x264.exe ../builds/64
# ALL DONE; LET'S HAVE A DRINK!
# golgol's git gpac because the cvs/svn is always borked
# ./configure --cpu=x86_64 --prefix=/mingw/${P64B} --cross-prefix=${P64B}-
# ./configure --prefix=mingw/i686-pc-mingw32
# make lib
# FOR SOME REASON make lib BUILDS ALL :D lol GPAC
# make install-lib
# make y4m
# ffmpeg.exe -i zeromatest.mp4 -f yuv4mpegpipe -vf "crop=0:0:0:180" zeroma.y4m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment