FFmpeg-編譯靜態(tài)庫(iOS)

FFmpeg是一套可以用來記錄吐辙、轉(zhuǎn)換數(shù)字音頻、視頻蘸劈,并能將其轉(zhuǎn)化為流的開源計算機程序昏苏。采用LGPL或GPL許可證。它提供了錄制、轉(zhuǎn)換以及流化音視頻的完整解決方案贤惯。它包含了非常先進的音頻/視頻編解碼庫libavcodec洼专,為了保證高可移植性和編解碼質(zhì)量,libavcodec里很多code都是從頭開發(fā)的孵构。
FFmpeg在Linux平臺下開發(fā)屁商,但它同樣也可以在其它操作系統(tǒng)環(huán)境中編譯運行,包括Windows颈墅、Mac OS X等蜡镶。這個項目最早由Fabrice Bellard發(fā)起,2004年至2015年間由Michael Niedermayer主要負責維護精盅。許多FFmpeg的開發(fā)人員都來自MPlayer項目帽哑,而且當前FFmpeg也是放在MPlayer項目組的服務(wù)器上。項目的名稱來自MPEG視頻編碼標準叹俏,前面的"FF"代表"Fast Forward"妻枕。


使用Shell腳本語言編譯音視頻.a靜態(tài)庫

第一步:下載音視頻框架

網(wǎng)上下載,非常簡單

官網(wǎng)地址:http://www.ffmpeg.org/download.html

通過Shell腳本下載音視頻框架

腳本代碼

#!/bin/bash
#庫名稱
source="ffmpeg-3.4"
#下載這個庫
if [ ! -r $source ]
then
    #沒有下載粘驰,那么執(zhí)行下載操作
    echo "沒有FFmpeg庫屡谐, 我們需要下載。蝌数。愕掏。。顶伞。饵撑。"
    #下載
    curl  http://ffmpeg.org/releases/${source}.tar.bz2 | tar xj || exit 1
fi

'curl'命令:它可以通過http/ftp等這樣的網(wǎng)絡(luò)方式下載和上傳文件(一個強大網(wǎng)絡(luò)工具),
基本格式:curl 地址
${source}.tar.bz2:制定下載版本
tar:表示解壓和壓縮唆貌,語法:tar options滑潘,例如:tar xj (x表示解壓文件選項,j表示需要解壓bz2壓縮包)

第二步:查看FFmpeg音視頻編譯配置選項

1锨咙、查看選項
  • 進入FFmpeg框架包中
  • 執(zhí)行命令查看配置 ./configure --help
Help options:
  --help                   print this message
  --quiet                  Suppress showing informative output
  --list-decoders          show all available decoders
  --list-encoders          show all available encoders
  --list-hwaccels          show all available hardware accelerators
  --list-demuxers          show all available demuxers
  --list-muxers            show all available muxers
  --list-parsers           show all available parsers
  --list-protocols         show all available protocols
  --list-bsfs              show all available bitstream filters
  --list-indevs            show all available input devices
  --list-outdevs           show all available output devices
  --list-filters           show all available filters

Standard options:
  --logfile=FILE           log tests and output to FILE [ffbuild/config.log]
  --disable-logging        do not log configure debug information
  --fatal-warnings         fail if any configure warning is generated
  --prefix=PREFIX          install in PREFIX [/usr/local]
  --bindir=DIR             install binaries in DIR [PREFIX/bin]
  --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]
  --docdir=DIR             install documentation in DIR [PREFIX/share/doc/ffmpeg]
  --libdir=DIR             install libs in DIR [PREFIX/lib]
  --shlibdir=DIR           install shared libs in DIR [LIBDIR]
  --incdir=DIR             install includes in DIR [PREFIX/include]
  --mandir=DIR             install man page in DIR [PREFIX/share/man]
  --pkgconfigdir=DIR       install pkg-config files in DIR [LIBDIR/pkgconfig]
  --enable-rpath           use rpath to allow installing libraries in paths
                           not part of the dynamic linker search path
                           use rpath when linking programs (USE WITH CARE)
  --install-name-dir=DIR   Darwin directory name for installed targets

Licensing options:
  --enable-gpl             allow use of GPL code, the resulting libs
                           and binaries will be under GPL [no]
  --enable-version3        upgrade (L)GPL to version 3 [no]
  --enable-nonfree         allow use of nonfree code, the resulting libs
                           and binaries will be unredistributable [no]

Configuration options:
  --disable-static         do not build static libraries [no]
  --enable-shared          build shared libraries [no]
  --enable-small           optimize for size instead of speed
  --disable-runtime-cpudetect disable detecting CPU capabilities at runtime (smaller binary)
  --enable-gray            enable full grayscale support (slower color)
  --disable-swscale-alpha  disable alpha channel support in swscale
  --disable-all            disable building components, libraries and programs
  --disable-autodetect     disable automatically detected external libraries [no]

Program options:
  --disable-programs       do not build command line programs
  --disable-ffmpeg         disable ffmpeg build
  --disable-ffplay         disable ffplay build
  --disable-ffprobe        disable ffprobe build
  --disable-ffserver       disable ffserver build

Documentation options:
  --disable-doc            do not build documentation
  --disable-htmlpages      do not build HTML documentation pages
  --disable-manpages       do not build man documentation pages
  --disable-podpages       do not build POD documentation pages
  --disable-txtpages       do not build text documentation pages

Component options:
  --disable-avdevice       disable libavdevice build
  --disable-avcodec        disable libavcodec build
  --disable-avformat       disable libavformat build
  --disable-swresample     disable libswresample build
  --disable-swscale        disable libswscale build
  --disable-postproc       disable libpostproc build
  --disable-avfilter       disable libavfilter build
  --enable-avresample      enable libavresample build [no]
  --disable-pthreads       disable pthreads [autodetect]
  --disable-w32threads     disable Win32 threads [autodetect]
  --disable-os2threads     disable OS/2 threads [autodetect]
  --disable-network        disable network support [no]
  --disable-dct            disable DCT code
  --disable-dwt            disable DWT code
  --disable-error-resilience disable error resilience code
  --disable-lsp            disable LSP code
  --disable-lzo            disable LZO decoder code
  --disable-mdct           disable MDCT code
  --disable-rdft           disable RDFT code
  --disable-fft            disable FFT code
  --disable-faan           disable floating point AAN (I)DCT code
  --disable-pixelutils     disable pixel utils in libavutil

Individual component options:
  --disable-everything     disable all components listed below
  --disable-encoder=NAME   disable encoder NAME
  --enable-encoder=NAME    enable encoder NAME
  --disable-encoders       disable all encoders
  --disable-decoder=NAME   disable decoder NAME
  --enable-decoder=NAME    enable decoder NAME
  --disable-decoders       disable all decoders
  --disable-hwaccel=NAME   disable hwaccel NAME
  --enable-hwaccel=NAME    enable hwaccel NAME
  --disable-hwaccels       disable all hwaccels
  --disable-muxer=NAME     disable muxer NAME
  --enable-muxer=NAME      enable muxer NAME
  --disable-muxers         disable all muxers
  --disable-demuxer=NAME   disable demuxer NAME
  --enable-demuxer=NAME    enable demuxer NAME
  --disable-demuxers       disable all demuxers
  --enable-parser=NAME     enable parser NAME
  --disable-parser=NAME    disable parser NAME
  --disable-parsers        disable all parsers
  --enable-bsf=NAME        enable bitstream filter NAME
  --disable-bsf=NAME       disable bitstream filter NAME
  --disable-bsfs           disable all bitstream filters
  --enable-protocol=NAME   enable protocol NAME
  --disable-protocol=NAME  disable protocol NAME
  --disable-protocols      disable all protocols
  --enable-indev=NAME      enable input device NAME
  --disable-indev=NAME     disable input device NAME
  --disable-indevs         disable input devices
  --enable-outdev=NAME     enable output device NAME
  --disable-outdev=NAME    disable output device NAME
  --disable-outdevs        disable output devices
  --disable-devices        disable all devices
  --enable-filter=NAME     enable filter NAME
  --disable-filter=NAME    disable filter NAME
  --disable-filters        disable all filters
  --disable-v4l2_m2m       disable V4L2 mem2mem code [autodetect]

External library support:

  Using any of the following switches will allow FFmpeg to link to the
  corresponding external library. All the components depending on that library
  will become enabled, if all their other dependencies are met and they are not
  explicitly disabled. E.g. --enable-libwavpack will enable linking to
  libwavpack and allow the libwavpack encoder to be built, unless it is
  specifically disabled with --disable-encoder=libwavpack.

  Note that only the system libraries are auto-detected. All the other external
  libraries must be explicitly enabled.

  Also note that the following help text describes the purpose of the libraries
  themselves, not all their features will necessarily be usable by FFmpeg.

  --disable-alsa           disable ALSA support [autodetect]
  --disable-appkit         disable Apple AppKit framework [autodetect]
  --disable-avfoundation   disable Apple AVFoundation framework [autodetect]
  --enable-avisynth        enable reading of AviSynth script files [no]
  --disable-bzlib          disable bzlib [autodetect]
  --disable-coreimage      disable Apple CoreImage framework [autodetect]
  --enable-chromaprint     enable audio fingerprinting with chromaprint [no]
  --enable-frei0r          enable frei0r video filtering [no]
  --enable-gcrypt          enable gcrypt, needed for rtmp(t)e support
                           if openssl, librtmp or gmp is not used [no]
  --enable-gmp             enable gmp, needed for rtmp(t)e support
                           if openssl or librtmp is not used [no]
  --enable-gnutls          enable gnutls, needed for https support
                           if openssl is not used [no]
  --disable-iconv          disable iconv [autodetect]
  --disable-jack           disable libjack support [autodetect]
  --enable-jni             enable JNI support [no]
  --enable-ladspa          enable LADSPA audio filtering [no]
  --enable-libass          enable libass subtitles rendering,
                           needed for subtitles and ass filter [no]
  --enable-libbluray       enable BluRay reading using libbluray [no]
  --enable-libbs2b         enable bs2b DSP library [no]
  --enable-libcaca         enable textual display using libcaca [no]
  --enable-libcelt         enable CELT decoding via libcelt [no]
  --enable-libcdio         enable audio CD grabbing with libcdio [no]
  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394
                           and libraw1394 [no]
  --enable-libfdk-aac      enable AAC de/encoding via libfdk-aac [no]
  --enable-libflite        enable flite (voice synthesis) support via libflite [no]
  --enable-libfontconfig   enable libfontconfig, useful for drawtext filter [no]
  --enable-libfreetype     enable libfreetype, needed for drawtext filter [no]
  --enable-libfribidi      enable libfribidi, improves drawtext filter [no]
  --enable-libgme          enable Game Music Emu via libgme [no]
  --enable-libgsm          enable GSM de/encoding via libgsm [no]
  --enable-libiec61883     enable iec61883 via libiec61883 [no]
  --enable-libilbc         enable iLBC de/encoding via libilbc [no]
  --enable-libkvazaar      enable HEVC encoding via libkvazaar [no]
  --enable-libmodplug      enable ModPlug via libmodplug [no]
  --enable-libmp3lame      enable MP3 encoding via libmp3lame [no]
  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  --enable-libopencv       enable video filtering via libopencv [no]
  --enable-libopenh264     enable H.264 encoding via OpenH264 [no]
  --enable-libopenjpeg     enable JPEG 2000 de/encoding via OpenJPEG [no]
  --enable-libopenmpt      enable decoding tracked files via libopenmpt [no]
  --enable-libopus         enable Opus de/encoding via libopus [no]
  --enable-libpulse        enable Pulseaudio input via libpulse [no]
  --enable-librsvg         enable SVG rasterization via librsvg [no]
  --enable-librubberband   enable rubberband needed for rubberband filter [no]
  --enable-librtmp         enable RTMP[E] support via librtmp [no]
  --enable-libshine        enable fixed-point MP3 encoding via libshine [no]
  --enable-libsmbclient    enable Samba protocol via libsmbclient [no]
  --enable-libsnappy       enable Snappy compression, needed for hap encoding [no]
  --enable-libsoxr         enable Include libsoxr resampling [no]
  --enable-libspeex        enable Speex de/encoding via libspeex [no]
  --enable-libssh          enable SFTP protocol via libssh [no]
  --enable-libtesseract    enable Tesseract, needed for ocr filter [no]
  --enable-libtheora       enable Theora encoding via libtheora [no]
  --enable-libtwolame      enable MP2 encoding via libtwolame [no]
  --enable-libv4l2         enable libv4l2/v4l-utils [no]
  --enable-libvidstab      enable video stabilization using vid.stab [no]
  --enable-libvmaf         enable vmaf filter via libvmaf [no]
  --enable-libvo-amrwbenc  enable AMR-WB encoding via libvo-amrwbenc [no]
  --enable-libvorbis       enable Vorbis en/decoding via libvorbis,
                           native implementation exists [no]
  --enable-libvpx          enable VP8 and VP9 de/encoding via libvpx [no]
  --enable-libwavpack      enable wavpack encoding via libwavpack [no]
  --enable-libwebp         enable WebP encoding via libwebp [no]
  --enable-libx264         enable H.264 encoding via x264 [no]
  --enable-libx265         enable HEVC encoding via x265 [no]
  --enable-libxavs         enable AVS encoding via xavs [no]
  --enable-libxcb          enable X11 grabbing using XCB [autodetect]
  --enable-libxcb-shm      enable X11 grabbing shm communication [autodetect]
  --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [autodetect]
  --enable-libxcb-shape    enable X11 grabbing shape rendering [autodetect]
  --enable-libxvid         enable Xvid encoding via xvidcore,
                           native MPEG-4/Xvid encoder exists [no]
  --enable-libxml2         enable XML parsing using the C library libxml2 [no]
  --enable-libzimg         enable z.lib, needed for zscale filter [no]
  --enable-libzmq          enable message passing via libzmq [no]
  --enable-libzvbi         enable teletext support via libzvbi [no]
  --disable-lzma           disable lzma [autodetect]
  --enable-decklink        enable Blackmagic DeckLink I/O support [no]
  --enable-libndi_newtek   enable Newteck NDI I/O support [no]
  --enable-mediacodec      enable Android MediaCodec support [no]
  --enable-libmysofa       enable libmysofa, needed for sofalizer filter [no]
  --enable-openal          enable OpenAL 1.1 capture support [no]
  --enable-opencl          enable OpenCL code
  --enable-opengl          enable OpenGL rendering [no]
  --enable-openssl         enable openssl, needed for https support
                           if gnutls is not used [no]
  --disable-sndio          disable sndio support [autodetect]
  --disable-schannel       disable SChannel SSP, needed for TLS support on
                           Windows if openssl and gnutls are not used [autodetect]
  --disable-sdl2           disable sdl2 [autodetect]
  --disable-securetransport disable Secure Transport, needed for TLS support
                           on OSX if openssl and gnutls are not used [autodetect]
  --disable-xlib           disable xlib [autodetect]
  --disable-zlib           disable zlib [autodetect]

  The following libraries provide various hardware acceleration features:
  --disable-audiotoolbox   disable Apple AudioToolbox code [autodetect]
  --disable-cuda           disable dynamically linked Nvidia CUDA code [autodetect]
  --enable-cuda-sdk        enable CUDA features that require the CUDA SDK [no]
  --disable-cuvid          disable Nvidia CUVID support [autodetect]
  --disable-d3d11va        disable Microsoft Direct3D 11 video acceleration code [autodetect]
  --disable-dxva2          disable Microsoft DirectX 9 video acceleration code [autodetect]
  --enable-libdrm          enable DRM code (Linux) [no]
  --enable-libmfx          enable Intel MediaSDK (AKA Quick Sync Video) code via libmfx [no]
  --enable-libnpp          enable Nvidia Performance Primitives-based code [no]
  --enable-mmal            enable Broadcom Multi-Media Abstraction Layer (Raspberry Pi) via MMAL [no]
  --disable-nvenc          disable Nvidia video encoding code [autodetect]
  --enable-omx             enable OpenMAX IL code [no]
  --enable-omx-rpi         enable OpenMAX IL code for Raspberry Pi [no]
  --enable-rkmpp           enable Rockchip Media Process Platform code [no]
  --disable-vaapi          disable Video Acceleration API (mainly Unix/Intel) code [autodetect]
  --disable-vda            disable Apple Video Decode Acceleration code [autodetect]
  --disable-vdpau          disable Nvidia Video Decode and Presentation API for Unix code [autodetect]
  --disable-videotoolbox   disable VideoToolbox code [autodetect]

Toolchain options:
  --arch=ARCH              select architecture []
  --cpu=CPU                select the minimum required CPU (affects
                           instruction selection, may crash on older CPUs)
  --cross-prefix=PREFIX    use PREFIX for compilation tools []
  --progs-suffix=SUFFIX    program name suffix []
  --enable-cross-compile   assume a cross-compiler is used
  --sysroot=PATH           root of cross-build tree
  --sysinclude=PATH        location of cross-build system headers
  --target-os=OS           compiler targets OS []
  --target-exec=CMD        command to run executables on target
  --target-path=DIR        path to view of build directory on target
  --target-samples=DIR     path to samples directory on target
  --tempprefix=PATH        force fixed dir/prefix instead of mktemp for checks
  --toolchain=NAME         set tool defaults according to NAME
  --nm=NM                  use nm tool NM [nm -g]
  --ar=AR                  use archive tool AR [ar]
  --as=AS                  use assembler AS []
  --ln_s=LN_S              use symbolic link tool LN_S [ln -s -f]
  --strip=STRIP            use strip tool STRIP [strip]
  --windres=WINDRES        use windows resource compiler WINDRES [windres]
  --x86asmexe=EXE          use nasm-compatible assembler EXE [nasm]
  --cc=CC                  use C compiler CC [gcc]
  --cxx=CXX                use C compiler CXX [g++]
  --objcc=OCC              use ObjC compiler OCC [gcc]
  --dep-cc=DEPCC           use dependency generator DEPCC [gcc]
  --nvcc=NVCC              use Nvidia CUDA compiler NVCC [nvcc]
  --ld=LD                  use linker LD []
  --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [pkg-config]
  --pkg-config-flags=FLAGS pass additional flags to pkgconf []
  --ranlib=RANLIB          use ranlib RANLIB [ranlib]
  --doxygen=DOXYGEN        use DOXYGEN to generate API doc [doxygen]
  --host-cc=HOSTCC         use host C compiler HOSTCC
  --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
  --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
  --host-ld=HOSTLD         use host linker HOSTLD
  --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host
  --host-libs=HLIBS        use libs HLIBS when linking for host
  --host-os=OS             compiler host OS []
  --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS []
  --extra-cxxflags=ECFLAGS add ECFLAGS to CXXFLAGS []
  --extra-objcflags=FLAGS  add FLAGS to OBJCFLAGS []
  --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS []
  --extra-ldexeflags=ELDFLAGS add ELDFLAGS to LDEXEFLAGS []
  --extra-ldlibflags=ELDFLAGS add ELDFLAGS to LDLIBFLAGS []
  --extra-libs=ELIBS       add ELIBS []
  --extra-version=STRING   version string suffix []
  --optflags=OPTFLAGS      override optimization-related compiler flags
  --nvccflags=NVCCFLAGS    override nvcc flags [-gencode arch=compute_30,code=sm_30 -O2]
  --build-suffix=SUFFIX    library name suffix []
  --enable-pic             build position-independent code
  --enable-thumb           compile for Thumb instruction set
  --enable-lto             use link-time optimization
  --env="ENV=override"     override the environment variables

Advanced options (experts only):
  --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
  --custom-allocator=NAME  use a supported custom allocator
  --disable-symver         disable symbol versioning
  --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  --disable-safe-bitstream-reader
                           disable buffer boundary checking in bitreaders
                           (faster, but may crash)
  --sws-max-filter-size=N  the max filter size swscale uses [256]

Optimization options (experts only):
  --disable-asm            disable all assembly optimizations
  --disable-altivec        disable AltiVec optimizations
  --disable-vsx            disable VSX optimizations
  --disable-power8         disable POWER8 optimizations
  --disable-amd3dnow       disable 3DNow! optimizations
  --disable-amd3dnowext    disable 3DNow! extended optimizations
  --disable-mmx            disable MMX optimizations
  --disable-mmxext         disable MMXEXT optimizations
  --disable-sse            disable SSE optimizations
  --disable-sse2           disable SSE2 optimizations
  --disable-sse3           disable SSE3 optimizations
  --disable-ssse3          disable SSSE3 optimizations
  --disable-sse4           disable SSE4 optimizations
  --disable-sse42          disable SSE4.2 optimizations
  --disable-avx            disable AVX optimizations
  --disable-xop            disable XOP optimizations
  --disable-fma3           disable FMA3 optimizations
  --disable-fma4           disable FMA4 optimizations
  --disable-avx2           disable AVX2 optimizations
  --disable-aesni          disable AESNI optimizations
  --disable-armv5te        disable armv5te optimizations
  --disable-armv6          disable armv6 optimizations
  --disable-armv6t2        disable armv6t2 optimizations
  --disable-vfp            disable VFP optimizations
  --disable-neon           disable NEON optimizations
  --disable-inline-asm     disable use of inline assembly
  --disable-x86asm         disable use of standalone x86 assembly
  --disable-mipsdsp        disable MIPS DSP ASE R1 optimizations
  --disable-mipsdspr2      disable MIPS DSP ASE R2 optimizations
  --disable-msa            disable MSA optimizations
  --disable-mipsfpu        disable floating point MIPS optimizations
  --disable-mmi            disable Loongson SIMD optimizations
  --disable-fast-unaligned consider unaligned accesses slow

Developer options (useful when working on FFmpeg itself):
  --disable-debug          disable debugging symbols
  --enable-debug=LEVEL     set the debug level []
  --disable-optimizations  disable compiler optimizations
  --enable-extra-warnings  enable more compiler warnings
  --disable-stripping      disable stripping of executables and shared libraries
  --assert-level=level     0(default), 1 or 2, amount of assertion testing,
                           2 causes a slowdown at runtime.
  --enable-memory-poisoning fill heap uninitialized allocated space with arbitrary data
  --valgrind=VALGRIND      run "make fate" tests through valgrind to detect memory
                           leaks and errors, using the specified valgrind binary.
                           Cannot be combined with --target-exec
  --enable-ftrapv          Trap arithmetic overflows
  --samples=PATH           location of test samples for FATE, if not set use
                           $FATE_SAMPLES at make invocation time.
  --enable-neon-clobber-test check NEON registers for clobbering (should be
                           used only for debugging purposes)
  --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
                           should be used only for debugging purposes)
  --enable-random          randomly enable/disable components
  --disable-random
  --enable-random=LIST     randomly enable/disable specific components or
  --disable-random=LIST    component groups. LIST is a comma-separated list
                           of NAME[:PROB] entries where NAME is a component
                           (group) and PROB the probability associated with
                           NAME (default 0.5).
  --random-seed=VALUE      seed value for --enable/disable-random
  --disable-valgrind-backtrace do not print a backtrace under Valgrind
                           (only applies to --disable-optimizations builds)
  --enable-osfuzz          Enable building fuzzer tool
  --libfuzzer=PATH         path to libfuzzer
  --ignore-tests=TESTS     comma-separated list (without "fate-" prefix
                           in the name) of tests whose result is ignored
  --enable-linux-perf      enable Linux Performance Monitor API

NOTE: Object files are built at the place where configure is launched.

幫助文檔.png

標準選項.png

許可選項(侵權(quán)).png

配置備選選項.png

外部庫支持.png

工具鏈選項.png

優(yōu)化選項.png

開發(fā)者選項.png

第三步:編寫腳本代碼

#!/bin/bash

#1语卤、定義庫名稱
source="ffmpeg-3.4.2"
#2、定義一個臨時目錄酪刀,用于保存.c/.h/.m文件編譯后的.o文件
cache="cache"

#3粹舵、定義".a"靜態(tài)庫保存目錄 pwd獲取當前路徑
staticdir=`pwd`/"zrs-ffmpeg-iOS"

#4、添加ffmpeg配置選項
#交叉編譯 --enable-cross-compile
#禁止使用debug模式 --disable-debug
#禁用程序 --disable-programs 不允許去建立一些命令行程序
#不需要編譯文檔 --disable-doc
#允許建立與我們位置無關(guān)的代碼 --enable-pic(默認的)
configure_flags="--enable-cross-compile --disable-debug --disable-programs --disable-doc --enable-pic"

#5骂倘、定義默認的CPU平臺架構(gòu)類型
#arm64 armv7 真機CUP架構(gòu)類型
#xb6_64 i38 模擬器
archs="arm64 armv7 xb6_64 i386"

#6眼滤、指定我們的這個庫編譯系統(tǒng)版本 ios7.0以及以上版本使用
targetversion="7.0"

#7、開始編譯
#y表示允許編譯 n表示不允許編譯
#complie="y"
#我是動態(tài)接受命令行輸入CPU平臺架構(gòu)類型(傳入?yún)?shù))
#如果存在外部指令就執(zhí)行
if [ "$*" ]
then
    #存在輸入?yún)?shù)历涝,也就是說:外部指定需要編譯cpu架構(gòu)類型
    archs="$*"
fi

#8柠偶、安裝匯編器-yasm
#目的:通過軟件管理器(Homebrew)情妖,然后下載安裝(或者更新)我的匯編器
#判斷一下是否存在匯編器
if [ ! `which yasm`  ]
then
    #Homebrew:軟件管理器
    #下載一個軟件管理器:安裝睬关、卸載诱担、更新、搜索等等...
    #錯誤二:`which` brew
    #正確二:`which brew`
    if [ ! `which brew` ]
    then
        echo "安裝brew"
        ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
    fi
    echo "安裝yasm"
    #成功了
    #下載安裝這個匯編器
    #exit 1->安裝失敗了电爹,那么退出程序
    brew install yasm || exit 1
fi

#9蔫仙、循環(huán)編譯靜態(tài)庫
currentdir=`pwd`
for arch in $archs
do
    echo "開始編譯。丐箩。摇邦。。屎勘。"
    #9.1創(chuàng)建目錄
    #在編譯結(jié)果目錄下-創(chuàng)建對應(yīng)平臺架構(gòu)類型
    mkdir -p "$cache/$arch"
    #9.2進入到當前目錄下
    cd "$cache/$arch"
    #9.3配置編譯器的cou架構(gòu)類型 -制定當前編譯cpu架構(gòu)類型
    archflags="-arch $arch"
    #9.4判斷是模擬器還是真機.a靜態(tài)庫
    if [ "$arch" = "i386" -o "$arch" = "xb6_64" ]
    then
        #模擬器
        platform="iPhoneSimulator"
        #支持最小系統(tǒng)版本-iOS 系統(tǒng)
        archflags="$archflags -mios-simulator-version-min=$targetversion"
    else
        #真機
        #支持最小系統(tǒng)版本-iOS 系統(tǒng)
        archflags="$archflags -mios-version-min=$targetversion -fembed-bitcode"
        #注意優(yōu)化處理
        #如果架構(gòu)類型是"arm64"施籍,那么
        if [ "$arch" = "arm64" ]
        then
            #GNU匯編器(GNU Assembler),簡稱為GAS
            #GASPP->匯編器預處理程序
            #解決問題:分段錯誤
            #通俗一點:就是程序運行時,變量訪問越界一類的問題
            EXPORT="GASPP_FIX_XCODE5=1"
        fi
    fi
    #10概漱、正式編譯
    #tr命令可以對來自標準輸入的字符進行替換丑慎、壓縮和刪除
    #'[:upper:]'->將小寫轉(zhuǎn)成大寫
    #'[:lower:]'->將大寫轉(zhuǎn)成小寫
    #將platform->轉(zhuǎn)成大寫或者小寫
    echo "正式編譯...."
    XCRUN_SDK=`echo $platform | tr '[:upper:]' '[:lower:]'`
    #編譯器->編譯平臺
    CC="xcrun -sdk $XCRUN_SDK clang"

    #架構(gòu)類型->arm64
    if [ "$arch" = "arm64" ]
    then
    #音視頻默認一個編譯命令
    #preprocessor.pl幫助我們編譯FFmpeg->arm64位靜態(tài)庫
    AS="gas-preprocessor.pl -arch aarch64 -- $CC"
    else
    #默認編譯平臺
    AS="$CC"
    fi

    echo "執(zhí)行到了1"

    #目錄找到FFmepg編譯源代碼目錄->設(shè)置編譯配置->編譯FFmpeg源碼
    #--target-os:目標系統(tǒng)->darwin(mac系統(tǒng)早起版本名字)
    #darwin:是mac系統(tǒng)、iOS系統(tǒng)祖宗
    #--arch:CPU平臺架構(gòu)類型
    #--cc:指定編譯器類型選項
    #--as:匯編程序
    #$configure_flags最初配置
    #--extra-cflags
    #--prefix:靜態(tài)庫輸出目錄
    TMPDIR=${TMPDIR/%\/} $currentdir/$source/configure \
    --target-os=darwin \
    --arch=$arch \
    --cc="$CC" \
    --as="$AS" \
    $configure_flags \
    --extra-cflags="$archflags" \
    --extra-ldflags="$archflags" \
    --prefix="$staticdir/$arch" \
    || exit 1

    echo "執(zhí)行了"

    #解決問題->分段錯誤問題
    #安裝->導出靜態(tài)庫(編譯.a靜態(tài)庫)
    #執(zhí)行命令
    make -j3 install $EXPORT || exit 1
    #回到了我們的腳本文件目錄
    cd $currentdir
done

1瓤摧、將文件gas-preprocessor.pl放入執(zhí)行文件目錄下
2竿裂、執(zhí)行文件 傳入?yún)?shù)arm64 ./ffmpeg-build.sh arm64

文件在:鏈接: https://pan.baidu.com/s/1lWf3w-rbs8Io-J-qTSxwxQ 密碼: ene9

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市照弥,隨后出現(xiàn)的幾起案子腻异,更是在濱河造成了極大的恐慌,老刑警劉巖这揣,帶你破解...
    沈念sama閱讀 222,627評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件悔常,死亡現(xiàn)場離奇詭異,居然都是意外死亡给赞,警方通過查閱死者的電腦和手機机打,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,180評論 3 399
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來塞俱,“玉大人姐帚,你說我怎么就攤上這事≌涎模” “怎么了罐旗?”我有些...
    開封第一講書人閱讀 169,346評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長唯蝶。 經(jīng)常有香客問我九秀,道長,這世上最難降的妖魔是什么粘我? 我笑而不...
    開封第一講書人閱讀 60,097評論 1 300
  • 正文 為了忘掉前任鼓蜒,我火速辦了婚禮痹换,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘都弹。我一直安慰自己娇豫,他們只是感情好,可當我...
    茶點故事閱讀 69,100評論 6 398
  • 文/花漫 我一把揭開白布畅厢。 她就那樣靜靜地躺著冯痢,像睡著了一般。 火紅的嫁衣襯著肌膚如雪框杜。 梳的紋絲不亂的頭發(fā)上浦楣,一...
    開封第一講書人閱讀 52,696評論 1 312
  • 那天,我揣著相機與錄音咪辱,去河邊找鬼振劳。 笑死,一個胖子當著我的面吹牛油狂,可吹牛的內(nèi)容都是我干的历恐。 我是一名探鬼主播,決...
    沈念sama閱讀 41,165評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼选调,長吁一口氣:“原來是場噩夢啊……” “哼夹供!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起仁堪,我...
    開封第一講書人閱讀 40,108評論 0 277
  • 序言:老撾萬榮一對情侶失蹤哮洽,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后弦聂,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體鸟辅,經(jīng)...
    沈念sama閱讀 46,646評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,709評論 3 342
  • 正文 我和宋清朗相戀三年莺葫,在試婚紗的時候發(fā)現(xiàn)自己被綠了匪凉。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,861評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡捺檬,死狀恐怖再层,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情堡纬,我是刑警寧澤聂受,帶...
    沈念sama閱讀 36,527評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站烤镐,受9級特大地震影響蛋济,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜炮叶,卻給世界環(huán)境...
    茶點故事閱讀 42,196評論 3 336
  • 文/蒙蒙 一碗旅、第九天 我趴在偏房一處隱蔽的房頂上張望渡处。 院中可真熱鬧,春花似錦祟辟、人聲如沸医瘫。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,698評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽登下。三九已至,卻和暖如春叮喳,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背缰贝。 一陣腳步聲響...
    開封第一講書人閱讀 33,804評論 1 274
  • 我被黑心中介騙來泰國打工馍悟, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人剩晴。 一個月前我還...
    沈念sama閱讀 49,287評論 3 379
  • 正文 我出身青樓锣咒,卻偏偏與公主長得像,于是被迫代替她去往敵國和親赞弥。 傳聞我的和親對象是個殘疾皇子毅整,可洞房花燭夜當晚...
    茶點故事閱讀 45,860評論 2 361

推薦閱讀更多精彩內(nèi)容