由于项目的需求,需要在ffmpeg中编译libaacplus、libx264和libopus的编解码库。
解决方法:
1. windows下使用MinGW+msys+vs 2010
这种方法编译,会有提示找不到libaacplus>= 2.0.0版本
2.linux下使用zeranoe的脚本交叉编译windows版本的ffmpeg
这种方式编译,会提示:checking for /bin/bash... configure: error: cannot check for file existence when cross compiling
官方论坛也有人遇到这种问题,zeranoe怀疑是编译选项问题,但是没有给出最终的脚本。
我的方法:这几天一直尝试ubuntu下使用脚本交叉编译ffmpeg。各种aac编解码都成功编译出ffmpeg.exe ffplay.exe ffprobe.exe,而且可以正常使用。
唯独libaacplus。修改configure选项后,会提示找不到libaacplus>= 2.0.0版本。
1--> 分析,既然windows下可以编译通过libaacplus,同样的configure命令,应该是没有生成某些文件,或者是生成了,但是没有在指定的地方。脚本执行完,提示错误后,查看ubuntu下工作目录,没有发现libaacplus.a libaacplus.pc libaacplus.o之类的文件。
ubuntu下工作目录,我的为 /home/gong/ffmpeg-windows-build-helpers/
2--> 从windows编译结果中拷贝出libaacplus生成的三个文件夹include lib bin的相应文件,到工作目录/home/gong/ffmpeg-windows-build-helpers/sanbox/win32/libaacplus-2.0.2/下
我复制过来了 aacplus.h aacplus.pc aacplusenc.exe aacplus.a aacplus.la aacplus.so aacplus.so.2 aacplus.so.2.0.2
BUT!!!如果还发现不了,则对应复制到/home/gong/ffmpeg-windows-build-helpers-master/sandbox/mingw-w64-i686/i686-w64-mingw32/ 对应bin include lib文件夹。值得注意的是要把aacplus.pc放到lib/pkgconfig/下,(2013-06-29修改)
3--> 修改脚本。注释掉 build_all( ){ 里面的 build_libaacplus ,将这个if …… fi 判断整个注释掉。同时,修改config_options 添加 --enable-libaacplus
最终,脚本是这样的。已经被我改的面目全非了。
1 #!/usr/bin/env bash 2 ################################################################################ 3 # ffmpeg windows cross compile helper/downloader script 4 ################################################################################ 5 # Copyright (C) 2012 Roger Pack 6 # 7 # This program is free software: you can redistribute it and/or modify it under 8 # the terms of the GNU General Public License as published by the Free Software 9 # Foundation, either version 3 of the License, or (at your option) any later 10 # version. 11 # 12 # This program is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 # details. 16 # 17 # You should have received a copy of the GNU General Public License along with 18 # this program. If not, see <http://www.gnu.org/licenses/>. 19 # 20 # The GNU General Public License can be found in the LICENSE file. 21 22 yes_no_sel () { 23 unset user_input 24 local question="$1" 25 shift 26 while [[ "$user_input" != [YyNn] ]]; do 27 echo -n "$question" 28 read user_input 29 if [[ "$user_input" != [YyNn] ]]; then 30 clear; echo 'Your selection was not vaild, please try again.'; echo 31 fi 32 done 33 # downcase it 34 user_input=$(echo $user_input | tr '[A-Z]' '[a-z]') 35 } 36 37 check_missing_packages () { 38 local check_packages=('make' 'git' 'svn' 'gcc' 'autoconf' 'libtool' 'automake' 'yasm') 39 for package in "${check_packages[@]}"; do 40 type -P "$package" >/dev/null || missing_packages=("$package" "${missing_packages[@]}") 41 done 42 43 if [[ -n "${missing_packages[@]}" ]]; then 44 clear 45 echo "Could not find the following packages: ${missing_packages[@]}" 46 echo 'Install the missing packages before running this script.' 47 exit 1 48 fi 49 } 50 51 52 cur_dir="$(pwd)/sandbox" 53 cpu_count="$(grep -c processor /proc/cpuinfo)" # linux only <sigh> 54 original_cpu_count=$cpu_count 55 56 intro() { 57 cat <<EOL 58 ##################### Welcome ###################### 59 Welcome to the ffmpeg cross-compile builder-helper script. 60 Downloads and builds will be installed to directories within $cur_dir 61 If this is not ok, then exit now, and cd to the directory where you'd 62 like them installed, then run this script again. NB that once you build 63 your compilers, you can no longer rename the directory. 64 EOL 65 if [[ $sandbox_ok != 'y' ]]; then 66 yes_no_sel "Is ./sandbox ok [y/n]?" 67 if [[ "$user_input" = "n" ]]; then 68 exit 1 69 fi 70 fi 71 mkdir -p "$cur_dir" 72 cd "$cur_dir" 73 if [[ $disable_nonfree = "y" ]]; then 74 non_free="n" 75 else 76 yes_no_sel "Would you like to include non-free (non GPL compatible) libraries, like many aac encoders 77 The resultant binary will not be distributable, but might be useful for in-house use. Include non-free [y/n]?" 78 non_free="$user_input" # save it away 79 fi 80 81 #yes_no_sel "Would you like to compile with -march=native, which can get a few percent speedup 82 #but also makes it so you cannot distribute the binary to machines of other architecture/cpu 83 #(also note that you should only enable this if compiling on a VM on the same box you intend to target, otherwise 84 #it makes no sense) Use march=native? THIS IS JUST EXPERIMENTAL AND DOES NOT WORK FULLY YET--choose n typically. [y/n]?" 85 #march_native="$user_input" 86 } 87 88 install_cross_compiler() { 89 if [[ -f "mingw-w64-i686/compiler.done" || -f "mingw-w64-x86_64/compiler.done" ]]; then 90 echo "MinGW-w64 compiler of some type already installed, not re-installing it..." 91 if [[ $rebuild_compilers != "y" ]]; then 92 return # early exit 93 fi 94 fi 95 read -p 'First we will download and compile a gcc cross-compiler (MinGW-w64). 96 You will be prompted with a few questions as it installs (it takes quite awhile). 97 Enter to continue:' 98 99 wget http://zeranoe.com/scripts/mingw_w64_build/mingw-w64-build-3.1.0 -O mingw-w64-build-3.1.0 100 chmod u+x mingw-w64-build-3.1.0 101 ./mingw-w64-build-3.1.0 --mingw-w64-ver=svn --disable-nls --disable-shared --default-configure --clean-build --threads=pthreads-w32 || exit 1 # --disable-shared allows c++ to be distributed at all...which seemed necessary for some random dependency... 102 if [ -d mingw-w64-x86_64 ]; then 103 touch mingw-w64-x86_64/compiler.done 104 fi 105 if [ -d mingw-w64-i686 ]; then 106 touch mingw-w64-i686/compiler.done 107 fi 108 clear 109 echo "Ok, done building MinGW-w64 cross-compiler..." 110 } 111 112 setup_env() { 113 export PKG_CONFIG_LIBDIR= # disable pkg-config from reverting back to and finding system installed packages [yikes] 114 } 115 116 do_svn_checkout() { 117 repo_url="$1" 118 to_dir="$2" 119 if [ ! -d $to_dir ]; then 120 echo "svn checking out to $to_dir" 121 svn checkout $repo_url $to_dir.tmp || exit 1 122 mv $to_dir.tmp $to_dir 123 else 124 cd $to_dir 125 echo "not svn Updating $to_dir since usually svn repo's aren't frequently updated..." 126 # svn up 127 cd .. 128 fi 129 } 130 131 update_to_desired_branch_or_revision() { 132 local to_dir="$1" 133 local desired_branch="$2" 134 if [ -n "$desired_branch" ]; then 135 pushd $to_dir 136 cd $to_dir 137 echo "git checkout $desired_branch" 138 git checkout "$desired_branch" 139 git merge "$desired_branch" # depending on which type it is :) 140 popd # in case it's a cd to ., don't want to cd to .. here... 141 fi 142 echo "now in" 143 echo `pwd` 144 } 145 146 do_git_checkout() { 147 local repo_url="$1" 148 local to_dir="$2" 149 local desired_branch="$3" 150 if [ ! -d $to_dir ]; then 151 echo "Downloading (via git clone) $to_dir" 152 # prevent partial checkouts by renaming it only after success 153 git clone $repo_url $to_dir.tmp || exit 1 154 mv $to_dir.tmp $to_dir 155 echo "done downloading $to_dir" 156 update_to_desired_branch_or_revision $to_dir $desired_branch 157 else 158 cd $to_dir 159 echo "Updating to latest $to_dir version..." 160 old_git_version=`git rev-parse HEAD` 161 #git pull 162 update_to_desired_branch_or_revision "." $desired_branch 163 new_git_version=`git rev-parse HEAD` 164 if [[ "$old_git_version" != "$new_git_version" ]]; then 165 echo "got upstream changes, forcing re-configure." 166 rm already* 167 fi 168 cd .. 169 fi 170 } 171 172 do_configure() { 173 local configure_options="$1" 174 local configure_name="$2" 175 if [[ "$configure_name" = "" ]]; then 176 configure_name="./configure" 177 fi 178 local cur_dir2=$(pwd) 179 local english_name=$(basename $cur_dir2) 180 local touch_name=$(echo -- $configure_options | /usr/bin/env md5sum) # sanitize, make it not too long of overall length 181 touch_name=$(echo already_configured_$touch_name | sed "s/ //g") # add a prefix so we can delete it easily, also remove spaces 182 if [ ! -f "$touch_name" ]; then 183 make clean # just in case 184 #make uninstall # does weird things when run under ffmpeg src 185 if [ -f bootstrap.sh ]; then 186 ./bootstrap.sh 187 fi 188 rm -f already_* # reset 189 echo "configuring $english_name as $ PATH=$PATH $configure_name $configure_options" 190 "$configure_name" $configure_options || exit 1 191 touch -- "$touch_name" 192 make clean # just in case 193 else 194 echo "already configured $(basename $cur_dir2)" 195 fi 196 } 197 198 do_make() { 199 local extra_make_options="$1 -j $cpu_count" 200 local cur_dir2=$(pwd) 201 if [ ! -f already_ran_make ]; then 202 echo "making $cur_dir2 as $ PATH=$PATH make $extra_make_options" 203 make $extra_make_options || exit 1 204 touch already_ran_make 205 else 206 echo "already did make $(basename "$cur_dir2")" 207 fi 208 } 209 210 do_make_install() { 211 local extra_make_options="$1" 212 do_make "$extra_make_options" 213 if [ ! -f already_ran_make_install ]; then 214 echo "make installing $cur_dir2 as $ PATH=$PATH make install $extra_make_options" 215 make install $extra_make_options || exit 1 216 touch already_ran_make_install 217 fi 218 } 219 220 build_x264() { 221 do_git_checkout "http://repo.or.cz/r/x264.git" "x264" "origin/stable" 222 cd x264 223 do_configure "--host=$host_target --enable-static --cross-prefix=$cross_prefix --prefix=$mingw_w64_x86_64_prefix --extra-cflags=-DPTW32_STATIC_LIB" #--enable-win32thread --enable-debug" 224 # TODO more march=native here? 225 # rm -f already_ran_make # just in case the git checkout did something, re-make 226 do_make_install 227 cd .. 228 } 229 230 231 build_librtmp() { 232 # download_and_unpack_file http://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3.tgz rtmpdump-2.3 # has some odd configure failure 233 # cd rtmpdump-2.3/librtmp 234 235 do_git_checkout "http://repo.or.cz/r/rtmpdump.git" rtmpdump_git 883c33489403ed360a01d1a47ec76d476525b49e # trunk didn't build once...this one i sstable 236 cd rtmpdump_git/librtmp 237 do_make_install "CRYPTO=GNUTLS OPT=-O2 CROSS_COMPILE=$cross_prefix SHARED=no prefix=$mingw_w64_x86_64_prefix" 238 #make install CRYPTO=GNUTLS OPT='-O2 -g' "CROSS_COMPILE=$cross_prefix" SHARED=no "prefix=$mingw_w64_x86_64_prefix" || exit 1 239 sed -i 's/-lrtmp -lz/-lrtmp -lwinmm -lz/' "$PKG_CONFIG_PATH/librtmp.pc" 240 cd ../.. 241 } 242 243 build_libxavs() { 244 do_svn_checkout https://xavs.svn.sourceforge.net/svnroot/xavs/trunk xavs 245 cd xavs 246 export LDFLAGS='-lm' 247 generic_configure # unfortunately this using --host isn't enough apparently... 248 unset LDFLAGS 249 do_make_install "CC=$(echo $cross_prefix)gcc AR=$(echo $cross_prefix)ar PREFIX=$mingw_w64_x86_64_prefix RANLIB=$(echo $cross_prefix)ranlib STRIP=$(echo $cross-prefix)strip" 250 cd .. 251 } 252 253 build_libvpx() { 254 do_git_checkout git://git.chromium.org/git/webm/libvpx.git "libvpx_git" 255 cd libvpx_git 256 export CROSS="$cross_prefix" 257 if [[ "$bits_target" = "32" ]]; then 258 do_configure "--extra-cflags=-DPTW32_STATIC_LIB --target=x86-win32-gcc --prefix=$mingw_w64_x86_64_prefix --enable-static --disable-shared" 259 else 260 do_configure "--extra-cflags=-DPTW32_STATIC_LIB --target=x86_64-win64-gcc --prefix=$mingw_w64_x86_64_prefix --enable-static --disable-shared " 261 fi 262 do_make_install 263 unset CROSS 264 cd .. 265 } 266 267 apply_patch() { 268 local url=$1 269 local patch_name=$(basename $url) 270 local patch_done_name="$patch_name.done" 271 if [[ ! -e $patch_done_name ]]; then 272 wget $url # might save redundantly to .1 or .2, but that's ok 273 patch -p0 < "$patch_name" #|| exit 1 274 touch $patch_done_name 275 else 276 echo "patch $patch_name already applied" 277 fi 278 } 279 280 281 build_libutvideo() { 282 download_and_unpack_file https://github.com/downloads/rdp/FFmpeg/utvideo-11.1.1-src.zip utvideo-11.1.1 283 cd utvideo-11.1.1 284 apply_patch https://raw.github.com/rdp/ffmpeg-windows-build-helpers/master/patches/utv.diff 285 make install CROSS_PREFIX=$cross_prefix DESTDIR=$mingw_w64_x86_64_prefix prefix= 286 cd .. 287 } 288 289 download_and_unpack_file() { 290 url="$1" 291 output_name=$(basename $url) 292 output_dir="$2" 293 if [ ! -f "$output_dir/unpacked.successfully" ]; then 294 wget "$url" -O "$output_name" || exit 1 295 tar -xf "$output_name" || unzip $output_name || exit 1 296 touch "$output_dir/unpacked.successfully" 297 rm "$output_name" 298 fi 299 } 300 301 generic_configure() { 302 local extra_configure_options="$1" 303 do_configure "--host=$host_target --prefix=$mingw_w64_x86_64_prefix --disable-shared --enable-static $extra_configure_options" 304 } 305 306 # needs 2 parameters currently 307 generic_download_and_install() { 308 local url="$1" 309 local english_name="$2" 310 local extra_configure_options="$3" 311 download_and_unpack_file $url $english_name 312 cd $english_name || exit "needs 2 parameters" 313 generic_configure_make_install $extra_configure_options 314 cd .. 315 } 316 317 generic_configure_make_install() { 318 generic_configure $1 319 do_make_install 320 } 321 322 build_libflite() { 323 download_and_unpack_file http://www.speech.cs.cmu.edu/flite/packed/flite-1.4/flite-1.4-release.tar.bz2 flite-1.4-release 324 cd flite-1.4-release 325 apply_patch https://raw.github.com/rdp/ffmpeg-windows-build-helpers/master/patches/flite_64.diff 326 sed -i "s|i386-mingw32-|$cross_prefix|" configure* 327 generic_configure 328 do_make 329 make install # it fails in error... 330 if [[ "$bits_target" = "32" ]]; then 331 cp ./build/i386-mingw32/lib/*.a $mingw_w64_x86_64_prefix/lib || exit 1 332 else 333 cp ./build/x86_64-mingw32/lib/*.a $mingw_w64_x86_64_prefix/lib || exit 1 334 fi 335 cd .. 336 } 337 338 build_libgsm() { 339 download_and_unpack_file http://www.quut.com/gsm/gsm-1.0.13.tar.gz gsm-1.0-pl13 340 cd gsm-1.0-pl13 341 make CC=${cross_prefix}gcc AR=${cross_prefix}ar RANLIB=${cross_prefix}ranlib INSTALL_ROOT=${mingw_w64_x86_64_prefix} # fails, but we expect that LODO fix [?] 342 cp lib/libgsm.a $mingw_w64_x86_64_prefix/lib || exit 1 343 mkdir -p $mingw_w64_x86_64_prefix/include/gsm 344 cp inc/gsm.h $mingw_w64_x86_64_prefix/include/gsm || exit 1 345 cd .. 346 } 347 348 build_libopus() { 349 generic_download_and_install http://downloads.xiph.org/releases/opus/opus-1.0.1.tar.gz opus-1.0.1 350 } 351 352 build_libopencore() { 353 generic_download_and_install http://sourceforge.net/projects/opencore-amr/files/opencore-amr/opencore-amr-0.1.3.tar.gz/download opencore-amr-0.1.3 354 generic_download_and_install http://sourceforge.net/projects/opencore-amr/files/vo-amrwbenc/vo-amrwbenc-0.1.2.tar.gz/download vo-amrwbenc-0.1.2 355 } 356 357 build_win32_pthreads() { 358 download_and_unpack_file ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.tar.gz pthreads-w32-2-9-1-release 359 cd pthreads-w32-2-9-1-release 360 do_make "clean GC-static CROSS=$cross_prefix" 361 cp libpthreadGC2.a $mingw_w64_x86_64_prefix/lib/libpthread.a || exit 1 362 cp pthread.h sched.h semaphore.h $mingw_w64_x86_64_prefix/include || exit 1 363 cd .. 364 } 365 366 build_libdl() { 367 #download_and_unpack_file http://dlfcn-win32.googlecode.com/files/dlfcn-win32-r19.tar.bz2 dlfcn-win32-r19 368 do_svn_checkout http://dlfcn-win32.googlecode.com/svn/trunk/ dlfcn-win32 369 cd dlfcn-win32 370 ./configure --disable-shared --enable-static --cross-prefix=$cross_prefix --prefix=$mingw_w64_x86_64_prefix 371 do_make_install 372 cd .. 373 } 374 375 build_libogg() { 376 generic_download_and_install http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz libogg-1.3.0 377 } 378 379 build_libvorbis() { 380 generic_download_and_install http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.3.tar.gz libvorbis-1.2.3 381 } 382 383 384 build_libtheora() { 385 cpu_count=1 # can't handle it 386 generic_download_and_install http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 libtheora-1.1.1 387 cpu_count=$original_cpu_count 388 } 389 390 build_libfribidi() { 391 generic_download_and_install http://fribidi.org/download/fribidi-0.19.5.tar.bz2 fribidi-0.19.5 392 #download_and_unpack_file http://fribidi.org/download/fribidi-0.19.4.tar.bz2 fribidi-0.19.4 393 #cd fribidi-0.19.4 394 # make it export symbols right... 395 # apply_patch https://raw.github.com/rdp/ffmpeg-windows-build-helpers/master/patches/fribidi.diff 396 # generic_configure 397 # do_make_install 398 #cd .. 399 400 #do_git_checkout http://anongit.freedesktop.org/git/fribidi/fribidi.git fribidi_git 401 #cd fribidi_git 402 # ./bootstrap 403 # generic_configure 404 # do_make_install 405 #cd .. 406 } 407 408 build_libass() { 409 generic_download_and_install http://libass.googlecode.com/files/libass-0.10.1.tar.gz libass-0.10.1 410 sed -i 's/-lass -lm/-lass -lfribidi -lm/' "$PKG_CONFIG_PATH/libass.pc" 411 } 412 413 build_gmp() { 414 download_and_unpack_file ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.bz2 gmp-5.0.5 415 cd gmp-5.0.5 416 generic_configure "ABI=$bits_target" 417 do_make_install 418 cd .. 419 } 420 421 build_orc() { 422 generic_download_and_install http://code.entropywave.com/download/orc/orc-0.4.16.tar.gz orc-0.4.16 423 } 424 425 build_libbluray() { 426 generic_download_and_install ftp://ftp.videolan.org/pub/videolan/libbluray/0.2.3/libbluray-0.2.3.tar.bz2 libbluray-0.2.3 427 } 428 429 build_libschroedinger() { 430 download_and_unpack_file http://diracvideo.org/download/schroedinger/schroedinger-1.0.11.tar.gz schroedinger-1.0.11 431 cd schroedinger-1.0.11 432 generic_configure 433 sed -i 's/testsuite//' Makefile 434 do_make_install 435 sed -i 's/-lschroedinger-1.0$/-lschroedinger-1.0 -lorc-0.4/' "$PKG_CONFIG_PATH/schroedinger-1.0.pc" # yikes! 436 cd .. 437 } 438 439 build_gnutls() { 440 download_and_unpack_file ftp://ftp.gnu.org/gnu/gnutls/gnutls-3.0.22.tar.xz gnutls-3.0.22 441 cd gnutls-3.0.22 442 generic_configure "--disable-cxx" # don't need the c++ version, in an effort to cut down on size... LODO test difference... 443 do_make_install 444 cd .. 445 sed -i 's/-lgnutls *$/-lgnutls -lnettle -lhogweed -lgmp -lcrypt32 -lws2_32/' "$PKG_CONFIG_PATH/gnutls.pc" 446 } 447 448 build_libnettle() { 449 generic_download_and_install http://www.lysator.liu.se/~nisse/archive/nettle-2.5.tar.gz nettle-2.5 450 } 451 452 build_bzlib2() { 453 download_and_unpack_file http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz bzip2-1.0.6 454 cd bzip2-1.0.6 455 apply_patch https://raw.github.com/rdp/ffmpeg-windows-build-helpers/master/patches/bzip2_cross_compile.diff 456 do_make "CC=$(echo $cross_prefix)gcc AR=$(echo $cross_prefix)ar PREFIX=$mingw_w64_x86_64_prefix RANLIB=$(echo $cross_prefix)ranlib libbz2.a bzip2 bzip2recover install" 457 cd .. 458 } 459 460 build_zlib() { 461 download_and_unpack_file http://zlib.net/zlib-1.2.7.tar.gz zlib-1.2.7 462 cd zlib-1.2.7 463 do_configure "--static --prefix=$mingw_w64_x86_64_prefix" 464 do_make_install "CC=$(echo $cross_prefix)gcc AR=$(echo $cross_prefix)ar RANLIB=$(echo $cross_prefix)ranlib" 465 cd .. 466 } 467 468 build_libxvid() { 469 download_and_unpack_file http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz xvidcore 470 cd xvidcore/build/generic 471 if [ "$bits_target" = "64" ]; then 472 local config_opts="--build=x86_64-unknown-linux-gnu --disable-assembly" # kludgey work arounds for 64 bit 473 fi 474 do_configure "--host=$host_target --prefix=$mingw_w64_x86_64_prefix $config_opts" # no static option... 475 sed -i "s/-mno-cygwin//" platform.inc # remove old compiler flag that now apparently breaks us 476 do_make_install 477 cd http://www.cnblogs.com/.. 478 # force a static build after the fact 479 if [[ -f "$mingw_w64_x86_64_prefix/lib/xvidcore.dll" ]]; then 480 rm $mingw_w64_x86_64_prefix/lib/xvidcore.dll || exit 1 481 mv $mingw_w64_x86_64_prefix/lib/xvidcore.a $mingw_w64_x86_64_prefix/lib/libxvidcore.a || exit 1 482 fi 483 } 484 485 build_fontconfig() { 486 download_and_unpack_file http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.10.1.tar.gz fontconfig-2.10.1 487 cd fontconfig-2.10.1 488 generic_configure --disable-docs 489 do_make_install 490 cd .. 491 sed -i 's/-L${libdir} -lfontconfig[^l]*$/-L${libdir} -lfontconfig -lfreetype -lexpat/' "$PKG_CONFIG_PATH/fontconfig.pc" 492 } 493 494 build_libaacplus() { 495 download_and_unpack_file http://217.20.164.161/~tipok/aacplus/libaacplus-2.0.2.tar.gz libaacplus-2.0.2 496 cd libaacplus-2.0.2 497 if [[ ! -f configure ]]; then 498 ./autogen.sh PKG_CONFIG_PATH=/home/gong/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/i686-w64-mingw32/lib/pkgconfig LDFLAGS=-L/home/gong/ffmpeg-windows-build-helpers/sandbox/mingw-w64-i686/i686-w64-mingw32/lib 499 fi 500 #generic_configure_make_install 501 generic_configure 502 do_make_install 503 cd .. 504 } 505 506 build_openssl() { 507 download_and_unpack_file http://www.openssl.org/source/openssl-1.0.1c.tar.gz openssl-1.0.1c 508 cd openssl-1.0.1c 509 export cross="$cross_prefix" 510 export CC="${cross}gcc" 511 export AR="${cross}ar" 512 export RANLIB="${cross}ranlib" 513 if [ "$bits_target" = "32" ]; then 514 do_configure "--prefix=$mingw_w64_x86_64_prefix no-shared mingw" ./Configure 515 else 516 do_configure "--prefix=$mingw_w64_x86_64_prefix no-shared mingw64" ./Configure 517 fi 518 do_make_install 519 unset cross 520 unset CC 521 unset AR 522 unset RANLIB 523 cd .. 524 } 525 526 build_fdk_aac() { 527 #generic_download_and_install http://sourceforge.net/projects/opencore-amr/files/fdk-aac/fdk-aac-0.1.0.tar.gz/download fdk-aac-0.1.0 528 do_git_checkout git://github.com/mstorsjo/fdk-aac.git fdk-aac_git 529 cd fdk-aac_git 530 if [[ ! -f "configure" ]]; then 531 autoreconf -fiv 532 fi 533 generic_configure_make_install 534 cd .. 535 } 536 537 538 build_libexpat() { 539 generic_download_and_install http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download expat-2.1.0 540 } 541 542 build_iconv() { 543 generic_download_and_install http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz libiconv-1.14 544 } 545 546 build_freetype() { 547 generic_download_and_install http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz freetype-2.4.10 548 } 549 550 build_vo_aacenc() { 551 generic_download_and_install http://sourceforge.net/projects/opencore-amr/files/vo-aacenc/vo-aacenc-0.1.2.tar.gz/download vo-aacenc-0.1.2 552 } 553 554 build_sdl() { 555 # apparently ffmpeg expects prefix-sdl-config not sdl-config that they give us, so rename... 556 export CFLAGS=-DDECLSPEC= # avoid trac tickets 939 and 282 557 generic_download_and_install http://www.libsdl.org/release/SDL-1.2.15.tar.gz SDL-1.2.15 558 unset CFLAGS 559 mkdir temp 560 cd temp # so paths will work out right 561 local prefix=$(basename $cross_prefix) 562 local bin_dir=$(dirname $cross_prefix) 563 sed -i "s/-mwindows//" "$mingw_w64_x86_64_prefix/bin/sdl-config" # allow ffmpeg to output anything 564 sed -i "s/-mwindows//" "$PKG_CONFIG_PATH/sdl.pc" 565 cp "$mingw_w64_x86_64_prefix/bin/sdl-config" "$bin_dir/${prefix}sdl-config" # this is the only one in the PATH so use it for now 566 cd .. 567 rmdir temp 568 } 569 570 build_faac() { 571 generic_download_and_install http://downloads.sourceforge.net/faac/faac-1.28.tar.gz faac-1.28 "--with-mp4v2=no" 572 } 573 574 build_frei0r() { 575 #download_and_unpack_file http://www.piksel.no/frei0r/releases/frei0r-plugins-1.3.tar.gz frei0r-1.3 576 #cd frei0r-1.3 577 #do_configure " --build=mingw32 --host=$host_target --prefix=$mingw_w64_x86_64_prefix --disable-static --enable-shared" # see http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=5&t=312 578 #do_make_install 579 # we rely on external dll's for this one, so only need the header to enable it, for now 580 #cp include/frei0r.h $mingw_w64_x86_64_prefix/include 581 #cd .. 582 if [[ ! -f "$mingw_w64_x86_64_prefix/include/frei0r.h" ]]; then 583 wget https://raw.github.com/rdp/frei0r/master/include/frei0r.h -O $mingw_w64_x86_64_prefix/include/frei0r.h 584 fi 585 } 586 587 build_ffmpeg() { 588 do_git_checkout git://github.com/FFmpeg/FFmpeg.git ffmpeg_git 589 cd ffmpeg_git 590 if [ "$bits_target" = "32" ]; then 591 local arch=x86 592 else 593 local arch=x86_64 594 fi 595 596 config_options="--enable-static --arch=$arch --target-os=mingw32 --cross-prefix=$cross_prefix --pkg-config=pkg-config --enable-gpl --enable-version3 --enable-zlib --enable-bzlib --disable-w32threads --disable-debug --disable-doc --disable-ffserver --disable-postproc --disable-network --extra-cflags=-DPTW32_STATIC_LIB --enable-libopus --enable-libx264 --enable-libaacplus --disable-encoders --enable-encoder=libx264 --enable-encoder=libaacplus --enable-encoder=libopus --enable-encoder=pcm_s16le --disable-decoders --enable-decoder=aac --enable-decoder=h264 --enable-decoder=libopus --enable-decoder=pcm_s16le " # --enable-shared --enable-static --enable-w32threads --enable-libflite 597 if [[ "$non_free" = "y" ]]; then 598 config_options="$config_options --enable-nonfree " # --enable-libfaac -- faac deemed too poor quality and becomes the default -- add it in and uncomment the build_faac line to include it --enable-libaacplus 599 else 600 config_options="$config_options" 601 fi 602 603 if [[ "$native_build" = "y" ]]; then 604 config_options="$config_options --disable-runtime-cpudetect" 605 # TODO --cpu=host ... 606 else 607 config_options="$config_options --enable-runtime-cpudetect" 608 fi 609 610 do_configure "$config_options" 611 rm -f *.exe # just in case some library dependency was updated, force it to re-link... 612 rm already_ran_make 613 echo "doing ffmpeg make $(pwd)" 614 do_make 615 echo "Done! You will find $bits_target bit binaries in $(pwd)/ff{mpeg,probe,play}*.exe" 616 cd .. 617 } 618 619 build_all() { 620 build_win32_pthreads # vpx etc. depend on this--provided by the compiler build script now, though 621 #build_libdl # ffmpeg's frei0r implentation needs this 622 build_zlib # rtmp depends on it [as well as ffmpeg's optional but handy --enable-zlib] 623 build_bzlib2 # in case someone wants it [ffmpeg uses it] 624 #build_gmp # for libnettle 625 #build_libnettle # needs gmp 626 #build_gnutls # needs libnettle 627 628 #build_frei0r 629 #build_libutvideo 630 #build_libflite # too big 631 #build_libgsm 632 build_sdl # needed for ffplay to be created 633 build_libopus 634 #build_libopencore 635 build_libogg 636 #build_libspeex # needs libogg for exe's 637 #build_libvorbis # needs libogg 638 #build_libtheora # needs libvorbis, libogg 639 #build_orc 640 #build_libschroedinger # needs orc 641 #build_libbluray 642 #build_libxvid 643 #build_libxavs 644 build_x264 645 #build_lame 646 #build_libvpx 647 #build_vo_aacenc 648 #build_iconv # mplayer I think needs it for freetype [just it though] 649 #build_freetype 650 #build_libexpat 651 #build_fontconfig # needs expat, might need freetype, can use iconv, but I believe doesn't currently 652 #build_libfribidi 653 #build_libass # needs freetype, needs fribidi, needs fontconfig 654 #build_libopenjpeg 655 #build_libaacplus 656 #build_openssl # hopefully don't need it anymore, since we have gnutls... 657 #build_librtmp # needs gnutls [or openssl...] 658 build_ffmpeg 659 } 660 661 while true; do 662 case $1 in 663 -h | --help ) echo "options: --disable-nonfree=y --sandbox-ok=y --rebuild-compilers=y"; exit 0 ;; 664 --sandbox-ok=* ) sandbox_ok="${1#*=}"; shift ;; 665 --disable-nonfree=* ) disable_nonfree="${1#*=}"; shift ;; 666 --rebuild-compilers=* ) rebuild_compilers="${1#*=}"; shift ;; 667 -- ) shift; break ;; 668 -* ) echo "Error, unknown option: '$1'."; exit 1 ;; 669 * ) break ;; 670 esac 671 done 672 673 intro # remember to always run the intro, since it adjust pwd 674 check_missing_packages 675 install_cross_compiler # always run this, too, since it adjust the PATH 676 setup_env 677 678 original_path="$PATH" 679 if [ -d "mingw-w64-i686" ]; then # they installed a 32-bit compiler 680 echo "Building 32-bit ffmpeg..." 681 host_target='i686-w64-mingw32' 682 mingw_w64_x86_64_prefix="$cur_dir/mingw-w64-i686/$host_target" 683 export PATH="$cur_dir/mingw-w64-i686/bin:$original_path" 684 export PKG_CONFIG_PATH="$cur_dir/mingw-w64-i686/i686-w64-mingw32/lib/pkgconfig" 685 bits_target=32 686 cross_prefix="$cur_dir/mingw-w64-i686/bin/i686-w64-mingw32-" 687 mkdir -p win32 688 cd win32 689 build_all 690 cd .. 691 fi 692 693 if [ -d "mingw-w64-x86_64" ]; then # they installed a 64-bit compiler 694 echo "Building 64-bit ffmpeg..." 695 host_target='x86_64-w64-mingw32' 696 mingw_w64_x86_64_prefix="$cur_dir/mingw-w64-x86_64/$host_target" 697 export PATH="$cur_dir/mingw-w64-x86_64/bin:$original_path" 698 export PKG_CONFIG_PATH="$cur_dir/mingw-w64-x86_64/x86_64-w64-mingw32/lib/pkgconfig" 699 mkdir -p x86_64 700 bits_target=64 701 cross_prefix="$cur_dir/mingw-w64-x86_64/bin/x86_64-w64-mingw32-" 702 cd x86_64 703 build_all 704 cd .. 705 fi 706 707 echo 'done with ffmpeg cross compiler script'
相应地想一想,当时windows下编译失败,是不是也可以这样反过来操作呢?