Log in

View Full Version : [GUIDE] x264 Build Tutorial


jpsdr
15th September 2015, 14:02
If moderators find this usefull enough, they can stick it.

Sorry in advance for the english mystakes, my english is not excellent.

There was a tutorial on doom10 once, but as doom10 doesn't exist anymore, it's gone. It was from it i've learned my first steps.
So, after a long struggle and gathering of informations, i've finaly been able to get a working process, to compile x264.

I've first severals peoples to thanks, without them, i wouldn't been able to succed.
First komisar, who have been a great help.
Have also been a great help, and give me others basis, the L-SMASH Works tutorial of Bruno Rex here (https://github.com/BrunoReX/build-scripts/tree/master/L-SMASH).
Thanks also to MasterNobody, LoRd_MuldeR and others i may forget.

Now, begin the step by stop tutorial, begining form scratch. It's a Windows tutorial, but probably a lot of things can be used outside Windows.

jpsdr
15th September 2015, 14:04
GIT

You'll need at least git, and tortoise git can also be a great help.
You can get GIT here (https://git-scm.com/).
And tortoise git here (https://tortoisegit.org/download/).

I'll not explain how to use GIT (can't explain everything), but a quick search will allow you to know how to clone a repository, and pull regularly, that would be enough.

jpsdr
15th September 2015, 14:06
PART 1 : Building using MSYS2

Install of MSYS2

First, you have to install msys2, get the version you want (x86 and/or x64) here (http://msys2.github.io/).
Once installed, if leave to default, the installation directory will be C:\msys32 or C:\msys64, according you've installed the x86 or x64 version (or both).
Whatever it is, i'll call it from now "msys2 dir".
You'll also have 3 icons in "MSYS2 32bit" (or "MSYS2 64bit") menu. The msys2 shell, one mingw32 shell to build for x86 and one mingw64 shell to build for x64.

You have to install the necessary packages to be able to build things.
Start the msys2 shell, and inside use the following commands :


pacman -Sy
pacman -S --needed make autoconf autogen diffutils git p7zip patch perl python2 ruby subversion yasm wget mingw-w64-i686-gcc mingw-w64-i686-gettext mingw-w64-i686-crt-git mingw-w64-i686-libtool mingw-w64-i686-libjpeg-turbo mingw-w64-i686-libpng mingw-w64-i686-libxml2 mingw-w64-i686-tools-git mingw-w64-i686-glib2 pkg-config mingw-w64-i686-cmake nasm
pacman -S --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-gettext mingw-w64-x86_64-crt-git mingw-w64-x86_64-libtool mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-libpng mingw-w64-x86_64-libxml2 mingw-w64-x86_64-tools-git mingw-w64-x86_64-glib2 mingw-w64-x86_64-cmake


Close the shell with "exit".
Now, tools have been installed, now you should proceed with the update process, to be sure to have everything up to date.

Note : If you've installed both the x86 and x64 version of msys2, you have to do this for both versions.

jpsdr
15th September 2015, 14:07
Updates of MSYS2

msys2 is actualy active and frequenlty updated, so, it should be regularly updated.

We will first update the core.
Start the "msys2 shell", and inside use the following commands :


pacman -Sy
pacman --needed -S bash pacman pacman-mirrors msys2-runtime

Note : If your version of MSYS2 is recent enough (but not too much), for updating the core, you can use instead just the following command :

update-core

Close the window shell with [X], not with exit.

Note : If your version of MSYS2 is even more recent, update-core is not working anymore. You have to do :

pacman -Syuu

and follow the instructions.


Now, go in the "msys2 dir" and launch (double click on it) the autorebase.bat file.
Once finished, restart again the "msys2 shell", and finish the update with the following command :


pacman -Su


Close with exit, and autorebase again.
Update is now finished.

Note : Again, if you've installed both x86 and x64 versions of msys2, you have to do this for both versions.

jpsdr
15th September 2015, 14:11
GIT install of programs

We will install all the necessery programs in one directory, you can of course do what you want, but for this tutorial, i'll follow this guideline.

Create a "C:\x264_Prg\" directory.

Inside "C:\x264_Prg\" create a "ffmpeg-stable" subdirectory, get the last stable version here (https://www.ffmpeg.org/download.html) and decompress and put it inside.
In "ffmpeg-stable" directory create a "Build_x264" subdirectory.

Inside "C:\x264_Prg\" Clone git l-smash from here (https://github.com/l-smash/l-smash.git).
In "l-smash" directory create a "Build_x264" subdirectory.

Inside "C:\x264_Prg\" Clone git ffms2 from here (https://github.com/FFMS/ffms2.git).
In "ffms2" directory create a "Build_x264" subdirectory.

Inside "C:\x264_Prg\" Clone git x264 from here (git://git.videolan.org/x264.git) or... you can clone git from my github here (https://github.com/jpsdr/x264) (at you own risk ;)) to have t_mod version. There is also several different versions made by others people, (k_mod, nak5124, 7mod, etc...), choose the one you want.

Now, that everything is installed, we will compile ffmpeg and others libs to create the libpack for building the several x264 versions.

jpsdr
15th September 2015, 14:12
FFMPEG

In "C:\x264_Prg\" create a file named Build_ffmpeg_x264.sh.

Put the following inside :


cd ./ffmpeg-stable/Build_x264
_dir="/local-x264"
[[ "$1" = "32" ]] && _dir="${_dir}_x86"
[[ "$1" = "64" ]] && _dir="${_dir}_x64"
[[ "$2" = "posix" ]] && _dir="${_dir}/posix"
[[ "$2" = "win32" ]] && _dir="${_dir}/Win32threads"
[[ "$3" = "original" ]] && _dir="${_dir}/Original"
[[ "$3" = "tmod" ]] && _dir="${_dir}/t_mod"
[[ "$3" = "jpsdr" ]] && _dir="${_dir}/jpsdr"
_arch="x86"
_cf="-mfpmath=sse -march=pentium3 -msse -mtune=pentium3"
_ld="-static"
_threads="--enable-pthreads --disable-w32threads"
_cpu="--cpu=pentium3"
_extra="--enable-avresample --disable-hwaccels --disable-network --disable-bsfs --disable-indevs --disable-outdevs --disable-devices --disable-avdevice --disable-d3d11va"
[[ "$3" = "tmod" ]] && _extra="${_extra} --enable-protocol=file --enable-swscale --enable-version3 --enable-nonfree"
[[ "$3" = "tmod" ]] && _extra="${_extra} --disable-decoder=alac,amrnb,amrwb,ape,ass,atrac1,atrac3,atrac3p,ccaption,mpc7,mpc8,mpl2,msmpeg4_crystalhd,nellymoser,opus,paf_audio,comfortnoise,cook,dsd_*,dsicinaudio,dvbsub,dvdsub,evrc,g723_1,g729,pgssub,pictor,pjs,qcelp,qdm2,ra_144,ra_288,ralf,realtext,roq_dpcm,sami,shorten,sipr,smackaud,sol_dpcm,sonic,srt,ssa,stl,subrip,subviewer,subviewer1,tak,text,gsm,gsm_ms,iac,idf,imc,interplay_dpcm,jacosub,lib*,mace3,mace6,metasound,microdvd,movtext,truespeech,tta,twinvq,vc1_crystalhd,vc1_vdpau,ws_snd1,xan_dpcm,xbin,xsub"
[[ "$3" = "jpsdr" ]] && _extra="${_extra} --enable-protocol=file --enable-swscale --enable-version3 --enable-nonfree"
[[ "$3" = "jpsdr" ]] && _extra="${_extra} --disable-decoder=alac,amrnb,amrwb,ape,ass,atrac1,atrac3,atrac3p,ccaption,mpc7,mpc8,mpl2,msmpeg4_crystalhd,nellymoser,opus,paf_audio,comfortnoise,cook,dsd_*,dsicinaudio,dvbsub,dvdsub,evrc,g723_1,g729,pgssub,pictor,pjs,qcelp,qdm2,ra_144,ra_288,ralf,realtext,roq_dpcm,sami,shorten,sipr,smackaud,sol_dpcm,sonic,srt,ssa,stl,subrip,subviewer,subviewer1,tak,text,gsm,gsm_ms,iac,idf,imc,interplay_dpcm,jacosub,lib*,mace3,mace6,metasound,microdvd,movtext,truespeech,tta,twinvq,vc1_crystalhd,vc1_vdpau,ws_snd1,xan_dpcm,xbin,xsub"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-protocols --enable-protocol=file"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-muxers --enable-muxer=avi,rawvideo,yuv4mpegpipe"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-encoders --disable-filters"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-parser=aac,aac_latm,ac3,cook,dca,dvbsub,dvd_nav,dvdsub,flac,gsm,mlp,mpegaudio,opus,tak,vorbis"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-demuxer=aac,ac3,act,adf,adp,adx,aea,afc,aiff,amr,apc,ape,aqtitle,ass,ast,au,avr,bintext,bit,boa,brstm,caf,concat,daud,dsf,dts,dtshd,ea_cdata,eac3,epaf,ffmetadata,flac,g722,g723_1,g729,gsm,srt,stl,subviewer,subviewer1,sup,tak,tedcaptions,truehd,idf,ilbc,ircam,iss,jacosub,latm,libgme,libquvi,live_flv,loas,lrc,microdvd,mlp,mmf,mp3,mpc,mpc8,mpl2,mpsub,tta,txd,vobsub,voc,vplayer,vqf,w64,wav,msnwc_tcp,nistsphere,ogg,oma,pcm_*,pjs,pvf,qcp,realtext,redspark,rsd,rso,rtp,rtsp,sami,sap,sbg,sdp,shorten,sln,sol,sox,spdif,webm_dash_manifest,webvtt,wsaud,wv,xa,xwma"
[[ "$3" = "original" ]] && _extra="${_extra} --disable-decoder=aac,aac_latm,ac3,ac3_fixed,adpcm_*,alac,amrnb,amrwb,ape,ass,atrac1,atrac3,atrac3p,ccaption,mp3,mp3adu,mp3adufloat,mp3float,mp3on4,mp3on4float,mpc7,mpc8,mpeg1_vdpau,mpeg2_crystalhd,mpeg4_crystalhd,mpeg4_vdpau,mpeg_vdpau,mpeg_xvmc,mpl2,msmpeg4_crystalhd,nellymoser,opus,paf_audio,pcm_*,binkaudio_*,bmv_audio,comfortnoise,cook,dca,dsd_*,dsicinaudio,dvbsub,dvdsub,eac3,evrc,ffwavesynth,flac,g723_1,g729,pcm_*,pgssub,pictor,pjs,qcelp,qdm2,ra_144,ra_288,ralf,realtext,roq_dpcm,sami,shorten,sipr,smackaud,sol_dpcm,sonic,srt,ssa,stl,subrip,subviewer,subviewer1,tak,text,gsm,gsm_ms,h264_crystalhd,h264_vda,h264_vdpau,iac,idf,imc,interplay_dpcm,jacosub,lib*,mace3,mace6,metasound,microdvd,mlp,movtext,mp1,mp1float,mp2,mp2float,truehd,truespeech,tta,twinvq,vc1_crystalhd,vc1_vdpau,vmdaudio,vorbis,vplayer,wavpack,webvtt,wma*,wmv3_crystalhd,wmv3_vdpau,ws_snd1,xan_dpcm,xbin,xsub"
[[ "$1" = "64" ]] && _arch="${_arch}_64"
[[ "$3" = "original" ]] && _cf="${_cf} -U__STRICT_ANSI__"
[[ "$3" = "jpsdr" ]] && _cf=""
[[ "$1" = "64" ]] && _cf="-m64"
[[ "$3" = "jpsdr" ]] && _cf="${_cf} -mfpmath=sse -march=haswell -mavx -mavx2 -mtune=haswell"
[[ "$1" = "64" ]] && _ld="${_ld} -m64"
[[ "$2" = "win32" ]] && _threads="--disable-pthreads --enable-w32threads"
[[ "$1" = "64" ]] && _cpu=""
[[ "$3" = "jpsdr" ]] && _cpu="--cpu=haswell"
../configure --prefix=${_dir} --target-os=mingw32 --arch=${_arch} \
--extra-cflags="${_cf}" --extra-ldflags="${_ld}" \
--enable-static --disable-shared ${_threads} --enable-gpl \
--disable-debug --disable-programs --disable-doc \
${_extra} \
--enable-runtime-cpudetect --enable-memalign-hack --enable-postproc ${_cpu}
make -j1
make install
make clean


If you want to compile for x86, in msys2, start the mingw32 shell. If you want to compile for x64, start the mingw64 shell.
Warning : It seems for ffmpeg that to compile for x64, you have to be under an x64 OS.

In the mingw shell you have opened, go into the "C:\x264_Prg\" directory with the following command :


cd c:/x264_Prg


Now, you can launch the building script with the following command :

./Build_ffmpeg_x264.sh param1 param2 param3


Values of parameters are :
param1 : 32 or 64 : You will set if you target x86 or x64. You must nevertheless have launched the proper mingw shell.
param2 : posix or win32 : You will set if you will compile using posix or win32 threads.
param3 : original, tmod or jpsdr (well... this is the script i'm using... ;)).
- original : You'll build the libraries for original version, don't need to much extra, will just be a little smaller.
- tmod : You'll build the libraries for tmod and others versions, add a little more stuff.
- jpsdr : Identical to tmod, but compile targeting haswell cpu and use of avx/avx2 instructions. Not checked, but probably works only of you have an haswell on the PC you compile with.

Build all the versions you need, and be patient...

Now, we'll build l-smash.

jpsdr
15th September 2015, 16:57
l-smash

Warning : If you want to build the t_mod version of x264, you have to create a branch (with GIT, for exemple a branch named "x264_build") and apply the patch described here (https://astrataro.wordpress.com/l-smash-patch-for-x264-tmod/).

Before building, don't forget to git pull to get up to date version, and fecth&rebase if you've created a "x264_build" branch.

In "C:\x264_Prg\" create a file named Build_lsmash_x264.sh.

Put the following inside :


cd ./l-smash/Build_x264
_dir="/local-x264"
[[ "$1" = "32" ]] && _dir="${_dir}_x86"
[[ "$1" = "64" ]] && _dir="${_dir}_x64"
[[ "$2" = "posix" ]] && _dir="${_dir}/posix"
[[ "$2" = "win32" ]] && _dir="${_dir}/Win32threads"
[[ "$3" = "original" ]] && _dir="${_dir}/Original"
[[ "$3" = "tmod" ]] && _dir="${_dir}/t_mod"
[[ "$3" = "jpsdr" ]] && _dir="${_dir}/jpsdr"
_ld="-static"
_cf=""
[[ "$3" = "jpsdr" ]] && _cf="-march=haswell -mavx -mavx2 -mtune=haswell"
[[ "$1" = "64" ]] && _ld="${_ld} -m64"
[[ "$1" = "64" ]] && _cf="${_cf} -m64"
PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
../configure --prefix=${_dir} --extra-ldflags="${_ld}" --extra-cflags="${_cf}"
make -j1 lib
make install
make clean


Launch the building script with the following command :

./Build_lsmash_x264.sh param1 param2 param3


Parameters are the same than for ffmpeg.

Build all the versions you need, and... this time it'll be a lot faster.

Now, we'll build ffms2.

jpsdr
15th September 2015, 16:59
ffms2

For ffms2, you need to make a little patch to use it with x264.
Create a git branch called "x264_build", and make the following change in include\ffms.h, replace :

// And now for some symbol hide-and-seek...
#if defined(_WIN32) // MSVC
# if defined(FFMS_EXPORTS) // building the FFMS2 library itself, with visible API symbols
# define FFMS_API(ret) FFMS_EXTERN_C __declspec(dllexport) ret FFMS_CC

with

// And now for some symbol hide-and-seek...
#if defined(_MSC_VER) // MSVC
# if defined(FFMS_EXPORTS) // building the FFMS2 library itself, with visible API symbols
# define FFMS_API(ret) FFMS_EXTERN_C __declspec(dllexport) ret FFMS_CC

You just have to change _WIN32 by _MSC_VER.

Commit, and now you have your own branch ready for x264 use.

Before building, don't forget to git pull to get up to date version, and fecth&rebase.

In "C:\x264_Prg\" create a file named Build_ffms2_x264.sh.
Put the following inside :

cd ./ffms2/Build_x264
_dir="/local-x264"
[[ "$1" = "32" ]] && _dir="${_dir}_x86"
[[ "$1" = "64" ]] && _dir="${_dir}_x64"
[[ "$2" = "posix" ]] && _dir="${_dir}/posix"
[[ "$2" = "win32" ]] && _dir="${_dir}/Win32threads"
[[ "$3" = "original" ]] && _dir="${_dir}/Original"
[[ "$3" = "tmod" ]] && _dir="${_dir}/t_mod"
[[ "$3" = "jpsdr" ]] && _dir="${_dir}/jpsdr"
_lav_l="-L${_dir}/lib -lswscale -lavformat -lavcodec -lavutil -lm -lbz2 -lz -lpsapi -ladvapi32 -lshell32"
_lav_c="-I${_dir}/include"
_av_l="-L${_dir}/lib -lavresample -lavutil -lm"
_av_c="-I${_dir}/include"
[[ "$2" = "posix" ]] && _lav_l="${_lav_l} -pthread"
[[ "$3" = "tmod" ]] && _lav_l="${_lav_l} -lavresample -lswresample -lavfilter -lpostproc"
[[ "$3" = "jpsdr" ]] && _lav_l="${_lav_l} -lavresample -lswresample -lavfilter -lpostproc"
[[ "$3" = "original" ]] && _av_l=""
[[ "$3" = "original" ]] && _av_c=""
_cf="-Wno-deprecated-declarations"
_cxx="-Wno-deprecated-declarations"
_ld="-static"
[[ "$3" = "jpsdr" ]] && _cf="${_cf} -march=haswell -mavx -mavx2 -mtune=haswell"
[[ "$3" = "jpsdr" ]] && _cxx="${_cxx} -march=haswell -mavx -mavx2 -mtune=haswell"
[[ "$1" = "64" ]] && _cf="${_cf} -m64"
[[ "$1" = "64" ]] && _cxx="${_cxx} -m64"
[[ "$1" = "64" ]] && _ld="${_ld} -m64"
_host="i686-w64-mingw32"
[[ "$1" = "64" ]] && _host="x86_64-w64-mingw32"
PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
CFLAGS="${_cf}" \
CXXFLAGS="${_cxx}" \
LDFLAGS="${_ld}" \
../configure --prefix=${_dir} --build="i686-w64-mingw32" --host=${_host} \
--enable-static --disable-shared
make -j1
make install
make clean


Launch the building script with the following command :

./Build_ffms2_x264.sh param1 param2 param3


Parameters are the same than for ffmpeg.

Build all the versions you need, and... this time it'll be also faster.

Now, we are finaly ready for the final chapter of this first part, building x264.

jpsdr
16th September 2015, 12:32
x264

After the long road, we finaly reach the final destination.

Before building, don't forget to git pull to get up to date version, and fecth&rebase if necessary.

In "C:\x264_Prg\x264" (or any name you put your x264 git cloned files) create a file named Build_x264.sh.

Put the following inside :

_dir="/local-x264"
[[ "$1" = "32" ]] && _dir="${_dir}_x86"
[[ "$1" = "64" ]] && _dir="${_dir}_x64"
[[ "$2" = "posix" ]] && _dir="${_dir}/posix"
[[ "$2" = "win32" ]] && _dir="${_dir}/Win32threads"
[[ "$3" = "original" ]] && _dir="${_dir}/Original"
[[ "$3" = "tmod" ]] && _dir="${_dir}/t_mod"
[[ "$3" = "jpsdr" ]] && _dir="${_dir}/jpsdr"
_cf=""
_ld="-static"
_extra="--disable-opencl --enable-static --enable-strip"
[[ "$3" = "jpsdr" ]] && _cf="${_cf} -march=haswell -mavx -mavx2 -mtune=haswell"
[[ "$1" = "64" ]] && _extra="${_extra} --host=x86_64-w64-mingw32"
[[ "$2" = "posix" ]] && _extra="${_extra} --disable-win32thread"
[[ "$4" = "10" ]] && _extra="${_extra} --bit-depth=10"
[[ "$3" = "tmod" ]] && _extra="${_extra} --enable-nonfree"
[[ "$3" = "jpsdr" ]] && _extra="${_extra} --enable-nonfree"
PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
./configure --extra-cflags="${_cf}" --extra-ldflags="${_ld}" ${_extra}
make


You can change the make by :

make fprofiled VIDS="[your video path file]"

if you want.

In the mingw shell, change directory for the one you have x264 in :

cd x264

(this if you've name the subdirectory x264).
And then, launch the building script with the following command :

./Build_x264.sh param1 param2 param3 param4

Parameters param1 to param3 are the same than for ffmpeg.
param4 : 8 or 10 : You will set the bit depth you want to create.

Now, if you've for exemple compiled everything with the following parameters : 32 win32 tmod, when using the following command on the t_mod version :

./Build_x264.sh 32 win32 tmod 8

you should have :

platform: X86
byte order: little-endian
system: WINDOWS
cli: yes
libx264: internal
shared: no
static: yes
asm: yes
interlaced: yes
avs: avisynth
lavf: yes
ffms: yes
avi output: yes
audio: yes (raw, lavc)
mp4: lsmash
gpl: yes
nonfree: yes
thread: win32
opencl: no
filters: resize crop select_every hqdn3d pad vflip subtitles yadif
debug: no
gprof: no
strip: yes
LTO: no
PIC: no
bit depth: 8
chroma format: all


This ends the first part.

jpsdr
16th September 2015, 12:35
PART 2 : Using MSYS and komisar's builds

This will describe a different way to build x264, it was basicaly the way described in the doom10 tutorial, and it's the way i've begun with, and used during a long time. You can use both method on the same PC.

Install of MinGW

Create the following directory : "C:\MinGW"

Get one gcc version here (http://komisar.gin.by/mingw/index.html).

Unpack it inside the "C:\MinGW" directory.

Get the last win32 yasm version here (http://yasm.tortall.net/Download.html) (actualy when i'm writing this it's the yasm-1.3.0-win32.exe). Rename the file in yasm.exe and put it in "C:\MinGW\bin".

jpsdr
16th September 2015, 13:57
Install of MSYS

Note : This can be installed even with MSYS2 is installed, they are in different directories, and don't interfer with each others, unless you force things to mess up on purpose :D !

First, get MSYS-1.0.11.exe here (http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/) and install it. When prompted for the mingw location, enter the directory where you've put komisar's gcc build (it should be "C:/MinGW" if you haven't changed the default of this tutorial).

Possible stop point
It could be enough if you just want to compile x264, and use the packlibs of komisar for ffmpeg and all. It was what i've done during a long time. But, you're bound to komisar's builds of libpack, which is largely enough for standard x264, but not for t_mod version for exemple.
Don't misunderstand me, komisar is doing great job providing what is providing, i'm just saying that if you want more, learn how to do it and do it yourself. I must said that the learning process especialy for ffmpeg has been a little painfull...
But if you want to build your own ffmpeg and all versions using this second method, installation continues.

Get msysDTK-1.0.1.exe here (http://downloads.sourceforge.net/mingw/msysDTK-1.0.1.exe), and install it.

Now, all the others files to install are compressed files. They are not exe you install, but files you unpack and put directly on the msys directory.

Browsing and searching inside here (http://sourceforge.net/projects/mingw/files/MSYS/Base/) get all the following files and install them :

bash-3.1.23-1-msys-1.0.18-bin.tar.xz
bzip2-1.0.6-1-msys-1.0.17-bin.tar.lzma
coreutils-5.97-3-msys-1.0.13-bin.tar.lzma
coreutils-5.97-3-msys-1.0.13-ext.tar.lzma
diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma
file-5.04-1-msys-1.0.13-bin.tar.lzma
findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma
gawk-3.1.7-2-msys-1.0.13-bin.tar.lzma
gettext-0.18.1.1-1-msys-1.0.17-bin.tar.lzma
glib_2.34.3-1_win32.zip
grep-2.5.4-2-msys-1.0.13-bin.tar.lzma
gzip-1.3.12-2-msys-1.0.13-bin.tar.lzma
less-436-2-msys-1.0.13-bin.tar.lzma
libasprintf-0.18.1.1-1-msys-1.0.17-dll-0.tar.lzma
libbz2-1.0.6-1-msys-1.0.17-dll-1.tar.lzma
libcharset-1.14-1-msys-1.0.17-dll-1.tar.lzma
libgettextpo-0.18.1.1-1-msys-1.0.17-dll-0.tar.lzma
libiconv-1.14-1-msys-1.0.17-bin.tar.lzma
libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma
libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma
libltdl-2.4-1-msys-1.0.15-dll-7.tar.lzma
liblzma-5.0.3-1-msys-1.0.17-dll-5.tar.lzma
libmagic-5.04-1-msys-1.0.13-dll-1.tar.lzma
libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma
libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma
libtool-2.4-1-msys-1.0.15-bin.tar.lzma
locate-4.4.2-2-msys-1.0.13-bin.tar.lzma
make-3.81-3-msys-1.0.13-bin.tar.lzma
pkg-config_0.28-1_win32.zip
sed-4.2.1-2-msys-1.0.13-bin.tar.lzma
tar-1.23-1-msys-1.0.13-bin.tar.lzma
termcap-0.20050421_1-2-msys-1.0.13-bin.tar.lzma
texinfo-4.13a-2-msys-1.0.13-bin.tar.lzma
xz-5.0.3-1-msys-1.0.17-bin.tar.lzma
zlib-1.2.7-1-msys-1.0.17-dll.tar.lzma


Now, after you've finished, you have a msys setup able to compile ffmpeg.
You can now launch the shell using either the "MSYS" icon created on desktop, or with menu : MinGW -> MSYS -> MSYS.
Unlike the MSYS2 configuration, because using komisar's gcc version, there is no need for an x86 or an x64 specific mingw shell.

But msys is a closed project, so there is no updates anymore or anything. You could have guessed, it's been replaced (or updated) by MSYS2.

jpsdr
16th September 2015, 13:58
ffmpeg

To build ffmeg, there is no differences than first method, it's easy for this step.
Use the same script with the same parameters.

jpsdr
17th September 2015, 09:32
ffms2

ffms2 will be more troublesome.
Because of the way komisar's gcc is build, at least at the time i'm writing these lines, you can't compile version 2.21 and up, you can compile only until version 2.20.

To compile, you have to make changes in the building script. You have to change this :

_cf="-Wno-deprecated-declarations"
_cxx="-Wno-deprecated-declarations"
_ld="-static"

by this :

_cf="-I${_dir}/include -Wno-deprecated-declarations"
_cxx="-I${_dir}/include -Wno-deprecated-declarations"
_ld="-L${_dir}/lib -static"
#_cf="-Wno-deprecated-declarations"
#_cxx="-Wno-deprecated-declarations"
#_ld="-static"

and this :

PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \

by this :

#PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
LIBAV_LIBS="${_lav_l}" \
LIBAV_CFLAGS="${_lav_c}" \
AVRESAMPLE_LIBS="${_av_l}" \
AVRESAMPLE_CFLAGS="${_av_c}" \


You can now compile ffms2 using the script the same way as descrided in first method.

jpsdr
17th September 2015, 09:34
l-smash

Here to, there is no differences than first method, it's easy for this step.
Use the same script with the same parameters.

jpsdr
17th September 2015, 09:35
x264

Now, the last step.
You have to make changes in the building script also here, changing this :

_cf=""
_ld="-static"

into this :

_cf="-I${_dir}/include -L${_dir}/lib"
_ld="-I${_dir}/include -L${_dir}/lib -static"
#_cf=""
#_ld="-static"

and this :

PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \

into this :

#PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \

It's now the end of this tutorial, i hope it can and will be usefull to people.

You can also consider this as a guideline or canvas to help you understand all the necessary processes to build x264, to create you own specific way of building x264.

It's of course a Windows tutorial, but i think it may also be used as guideline for others OS.

Neroldy
17th September 2015, 16:48
Thanks a lot! I think it's a very useful tutorial.
Here is a 7mod x264 version which is very similar to tmod and still update with offical git.
https://github.com/Freecom/x264

pm12hpm
8th October 2015, 09:14
Nice gui! Stick it, plz, to the members as I easily search.

P/s: My build is ok?

platform: X86_64
byte order: little-endian
system: WINDOWS
cli: yes
libx264: internal
shared: no
static: no
asm: yes
interlaced: yes
avs: avisynth
lavf: yes
ffms: yes
avi output: yes
audio: yes (raw, lavc)
mp4: lsmash
gpl: yes
nonfree: yes
thread: posix
opencl: no
filters: resize crop select_every hqdn3d pad vflip subtitles yadif
debug: no
gprof: no
strip: no
LTO: no
PIC: no
bit depth: 8
chroma format: all

Full log: http://pastebin.com/cvwa79QP

jpsdr
9th October 2015, 10:42
Seems Ok.

komisar
9th October 2015, 12:06
why strip: no?
with static: no external .dll?

jpsdr
9th October 2015, 14:54
No idea about static, but the .exe has always worked without the need of extenal dll. Maybe static is relevant only when building the library, not the exe...? No idea what strip is (well... i know the meaning of the word... ;) but no idea what it is in that case).

foxyshadis
10th October 2015, 02:37
In coding, strip means "remove debug information." Even without specifically building debug, some debug information is embedded unless you strip it, so it's a part of most *nix builds.

jpsdr
10th October 2015, 15:37
Ok, thanks for the remarks and informations, i've updated the tutorial.

komisar
16th October 2015, 21:58
For latest git FFMS2 and non-POSIX gcc threaing model need this patch (http://komisar.gin.by/x.patch/no_c++11_threads.diff)

:) and `#if defined(_MSC_VER)` also need in ffms.h

jpsdr
20th October 2015, 17:36
What are the advantages of a non-POSIX gcc threading model ? (If any...)

komisar
20th October 2015, 18:52
In this case, ffms2 use threading for read number of CPU/working-threads... But when gcc compile without POSIX threading model on windows, this dont work. (You may make you app with POSIX thread, but gcc itself, and std::thread in c++11, dont)
As i understand guys use this for "unification" for C++11... But use this only for read number of CPU and break compatibilities with some compilers... This is a small/big question...

jpsdr
21st October 2015, 09:07
Your patch is not working with the standard actual version of ffms2, one reason is that the make files are not in the same directory than in your patch.

komisar
21st October 2015, 11:38
`patch -p1 <"no_c++11_threads.diff"` work for me with current git

jpsdr
21st October 2015, 12:25
I'll check again...

Ok, my mistake. I was mislead by tortoisegit which didn't display the red "!" on the make files after applying the patch.
Strange...

jpsdr
18th January 2016, 16:46
Update x264 build script after r2664.

Edit : Update also of ffmpeg build script.

jpsdr
1st April 2016, 12:53
Update of msys2 part since the last pacman update changes a little the process.

jpsdr
30th May 2016, 09:38
Update the install link of msys2. I ask again moderators if this can be sticked, because i think it's interesting enough to be. If not, at least can you tell me why, or what is missing or need to be done to be sticked ?
Thanks.

shekh
9th August 2016, 11:33
Can you explain how to invoke sh from windows shell? I tried passing it to sh.exe but got some shit.
Mingw tutorials just say "run configure as usual"..

jpsdr
9th August 2016, 22:51
Oops. Deleted wrong message. I'm using msys2 shell, not windows shell, as i've explained in the tutorial.

shekh
10th August 2016, 09:59
This works for me now (I had a stupid mistake in path command)
IMO much better than having to type commands in msys shell


@set msys=E:\work\ffmpeg_build\msys64
@set bin=%msys%\mingw32\bin
@path %path%;%bin%;%msys%\usr\bin

@set dir=%CD%
@cd E:\work\ffmpeg_build\build\x264-git\build-32bit

@sh ../configure --host=i686-w64-mingw32 --prefix=/local32 --enable-static --disable-cli
@make >%dir%\buildlib.log

@cd %dir%

jpsdr
10th August 2016, 15:15
Still not working for me with gcc 6.1.0, but only on 64 bit builds, works fine on 32 bit builds.
I must say i had no idea what magical compile command option to add. In the other thread i've put the config log result, if any expert can take a look and tell me why what was working for gcc 5.3.0 is not working anymore for gcc 6.1.0.

ghostshadow
4th March 2023, 16:40
hello @jpsdr I have an error using your script for ffm2:

$ ./Build_ffms2_x264.sh 64 posix jpsdr
./Build_ffms2_x264.sh: line 29: ../configure: No such file or directory
make: *** No targets specified and no makefile found. Stop.
make: *** No rule to make target 'install'. Stop.
make: *** No rule to make target 'clean'. Stop.


I can't find the error.

thank

jpsdr
6th March 2023, 18:32
OOOOOhhhh... A looot of things in this thread are obsolete.
I didn't maintain as was never able to make the admin stick it, and never had a reply of what is the process for asking to stick. As admin didn't care and were not interested in this, so do i.

Anyway, your issue is that there is no configure script anymore in ffms2. So copy autogen.sh, rename it autogen2.sh for exemple, delete the last line with configure and run the new version. It will create the configure file, and things will work again.

ghostshadow
9th March 2023, 19:05
thanks @jpsdr
I managed to get my codecs.

StainlessS
5th March 2024, 22:39
Yes thanx jpsdr, will be handy when I ever eventually try to compile a version of x264.

Methinks any guide to compiling a major open-source video related tool should be stickied, if only so people can find it.

jpsdr
6th March 2024, 19:47
As i've said, a loooooooooooooot of things have changed, and probably at least 50% should be re-written.
More... Now ffms2 changed the api, needing at least ffmpeg5, but to be able to use some patches wich are ooold, you can't go over ffmpeg4.
So, i had to create a specific branch of ffms2 just before the changes needing ffmpeg5 were commited. Meaning ffms2 is not frozen (at least in my releases).
The best for these patches would be to still being able to use ffmpeg2, but x264 needs at least ffmpeg3 i think.