Patman86 / x264-Mod-by-Patman

Patman's mod of x264
GNU General Public License v2.0
22 stars 1 forks source link

[Request] Guide on how to build #2

Closed firezt closed 9 months ago

firezt commented 3 years ago

Hi, firstly thank you so much for the mod! I was wondering if you could provide a guide on how to build from source? that would be pretty nice. 😃

Regards

Patman86 commented 3 years ago

Hi, I only saw your entry now. I use the following script (Build_Script_x264.sh) to create the x264.exe (including ffms2, l-smash) with msys or mingw. Based on [GUIDE] x264 Build Tutorial THX @jpsdr

[[ "$1" = "32" ]] && _mk="x86"
[[ "$1" = "64" ]] && _mk="x64"
[[ "$2" = "O" ]] && _source="x264"
[[ "$2" = "M" ]] && _source="x264M"
_dir=/h/repos/x264/opt
[[ "$1" = "32" ]] && _dir="${_dir}_x86"
[[ "$1" = "64" ]] && _dir="${_dir}_x64"
#ffmpeg
cd /h/repos/x264/ffmpeg
if [ ! -d build_${_mk} ]; then
mkdir -p build_${_mk}
cd build_${_mk}
_arch="--arch=x86"
_cf="-mfpmath=sse -msse -mtune=generic -U__STRICT_ANSI__"
_ld="-static"
_os="--target-os=mingw32"
_cpu="--cpu=pentium3"
_extra="--disable-hwaccels --disable-network --disable-bsfs --disable-indevs --disable-outdevs --disable-devices --disable-avdevice --disable-d3d11va --disable-protocols --enable-protocol=file --disable-muxers --enable-muxer=avi,rawvideo,yuv4mpegpipe --disable-encoders --disable-filters --disable-parser=aac,aac_latm,ac3,cook,dca,dvbsub,dvd_nav,dvdsub,flac,gsm,mlp,mpegaudio,opus,tak,vorbis --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 --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=x86_64"
[[ "$1" = "64" ]] && _cf="${_cf} -m64"
[[ "$1" = "64" ]] && _ld="${_ld} -m64"
[[ "$1" = "64" ]] && _os="--target-os=mingw64"
[[ "$1" = "64" ]] && _cpu=""
../configure --prefix=${_dir} ${_os} ${_arch} \
--extra-cflags="${_cf}" --extra-ldflags="${_ld}" \
--enable-static --disable-shared --enable-gpl \
--disable-debug --disable-programs --disable-doc \
${_extra} \
--enable-runtime-cpudetect --enable-postproc ${_cpu}
make -j1
make install
make clean
echo "ffmpeg compiling complete"
else
echo "ffmpeg exist -> next lsmash"
fi

#lsmash
cd /h/repos/x264/l-smash
if [ ! -d build_${_mk} ]; then
mkdir -p build_${_mk}
cd build_${_mk}
_ld="-static"
_cf=""
[[ "$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
echo "lsmash compiling complete"
else
echo "lsmash exist -> next ffms2"
fi

#ffms2
cd /h/repos/x264/ffms2
if [ ! -d src/config ]; then
mkdir -p src/config
autoreconf -ivf
else
echo "Directory already exists"
fi
if [ ! -d build_${_mk} ]; then
mkdir -p build_${_mk}
cd build_${_mk}
_lav_l="-L${_dir}/lib -lswscale -lavformat -lavcodec -lavutil -lm -lbz2 -lz -lpsapi -ladvapi32 -lshell32"
_lav_c="-I${_dir}/include"
_av_l=""
_av_c=""
_cf="-Wno-deprecated-declarations"
_cxx="-Wno-deprecated-declarations"
_ld="-static"
[[ "$1" = "64" ]] && _cf="${_cf} -m64"
[[ "$1" = "64" ]] && _cxx="${_cxx} -m64"
[[ "$1" = "64" ]] && _ld="${_ld} -m64"
_host="i686-w64-mingw32"
_build="i686-w64-mingw32"
[[ "$1" = "64" ]] && _host="x86_64-w64-mingw32"
[[ "$1" = "64" ]] && _build="x86_64-w64-mingw32"
PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
CFLAGS="${_cf}" \
CXXFLAGS="${_cxx}" \
LDFLAGS="${_ld}" \
../configure --prefix=${_dir} --build=${_build} --host=${_host} \
--enable-static --disable-shared
make -j1
make install
make clean
echo "ffms2 compiling complete"
else
echo "ffms2 exist -> next x264"
fi

#x264
cd /h/repos/x264/${_source}
if [ ! -d build_${_mk} ]; then
    mkdir -p build_${_mk}
else
    echo "Directory already exists"
fi
cd build_${_mk}
_cf=""
_ld="-static"
_extra="--enable-static --enable-strip"
[[ "$1" = "32" ]] && _extra="${_extra} --host=i686-w64-mingw32"
[[ "$1" = "64" ]] && _extra="${_extra} --host=x86_64-w64-mingw32"
PKG_CONFIG_PATH="${_dir}/lib/pkgconfig" \
../configure --extra-cflags="${_cf}" --extra-ldflags="${_ld}" --extra-ldflags="$(PKG_CONFIG_PATH=${_dir}/lib/pkgconfig pkg-config --libs --static ffms2) -lstdc++" --bindir=/h/repos/x264/${_mk}/${_source} ${_extra}
make
make install
make clean

rm -rf /h/repos/x264/${_source}/build_${_mk};

upx -9 --force -qq /h/repos/x264/${_mk}/${_source}/x264.exe
firezt commented 3 years ago

Thanks a lot! I'll try this tomorrow. Could you also share for x265? if there is one... TIA.

Patman86 commented 3 years ago

I'll post my build scripts ... maybe as a guide and a separate tab in the repository.