在看ijkPlayer源码的时候,发现ijkPlayer编译出来 的ffmpeg库和别人的不一样,因此这里特此想分析下脚本编译
init-ios.sh
#! /usr/bin/env bash
#
# Copyright (C) 2013-2015 Bilibili
# Copyright (C) 2013-2015 Zhang Rui <bbcallen@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# IJK_FFMPEG_UPSTREAM=git://git.videolan.org/ffmpeg.git
IJK_FFMPEG_UPSTREAM=https://github.com/Bilibili/FFmpeg.git
IJK_FFMPEG_FORK=https://github.com/Bilibili/FFmpeg.git
IJK_FFMPEG_COMMIT=ff3.4--ijk0.8.7--20180103--001
IJK_FFMPEG_LOCAL_REPO=extra/ffmpeg
IJK_GASP_UPSTREAM=https://github.com/Bilibili/gas-preprocessor.git
# gas-preprocessor backup
# https://github.com/Bilibili/gas-preprocessor.git
if [ "$IJK_FFMPEG_REPO_URL" != "" ]; then
IJK_FFMPEG_UPSTREAM=$IJK_FFMPEG_REPO_URL
IJK_FFMPEG_FORK=$IJK_FFMPEG_REPO_URL
fi
if [ "$IJK_GASP_REPO_URL" != "" ]; then
IJK_GASP_UPSTREAM=$IJK_GASP_REPO_URL
fi
set -e
TOOLS=tools
FF_ALL_ARCHS_IOS6_SDK="armv7 armv7s i386"
FF_ALL_ARCHS_IOS7_SDK="armv7 armv7s arm64 i386 x86_64"
FF_ALL_ARCHS_IOS8_SDK="armv7 arm64 i386 x86_64"
FF_ALL_ARCHS=$FF_ALL_ARCHS_IOS8_SDK
FF_TARGET=$1
function echo_ffmpeg_version() {
echo $IJK_FFMPEG_COMMIT
}
function pull_common() {
git --version
echo "== pull gas-preprocessor base =="
sh $TOOLS/pull-repo-base.sh $IJK_GASP_UPSTREAM extra/gas-preprocessor
echo "== pull ffmpeg base =="
sh $TOOLS/pull-repo-base.sh $IJK_FFMPEG_UPSTREAM $IJK_FFMPEG_LOCAL_REPO
}
function pull_fork() {
echo "== pull ffmpeg fork $1 =="
sh $TOOLS/pull-repo-ref.sh $IJK_FFMPEG_FORK ios/ffmpeg-$1 ${IJK_FFMPEG_LOCAL_REPO}
cd ios/ffmpeg-$1
git checkout ${IJK_FFMPEG_COMMIT} -B ijkplayer
cd -
}
function pull_fork_all() {
for ARCH in $FF_ALL_ARCHS
do
pull_fork $ARCH
done
}
function sync_ff_version() {
sed -i '' "s/static const char \*kIJKFFRequiredFFmpegVersion\ \=\ .*/static const char *kIJKFFRequiredFFmpegVersion = \"${IJK_FFMPEG_COMMIT}\";/g" ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m
}
#----------
case "$FF_TARGET" in
ffmpeg-version)
echo_ffmpeg_version
;;
armv7|armv7s|arm64|i386|x86_64)
pull_common
pull_fork $FF_TARGET
;;
all|*)
pull_common
pull_fork_all
;;
esac
sync_ff_version
首先,我们从ijkPlayer 中首先要先运行init-ios.sh脚本.因此这里分段分析该脚本
IJK_FFMPEG_UPSTREAM=https://github.com/Bilibili/FFmpeg.git
IJK_FFMPEG_FORK=https://github.com/Bilibili/FFmpeg.git
IJK_FFMPEG_COMMIT=ff3.4--ijk0.8.7--20180103--001
IJK_FFMPEG_LOCAL_REPO=extra/ffmpeg
IJK_GASP_UPSTREAM=https://github.com/Bilibili/gas-preprocessor.git
声明变量
IJK_FFMPEG_UPSTREAM 和IJK_FFMPEG_FORK 指向ffmpeg git地址
IJK_FFMPEG_LOCAL_REPO 应该是下载到本地的地址
IJK_GASP_UPSTREAM 是编译需要的一个汇编工具地址.
IJK_FFMPEG_COMMIT ffmeng提交的节点
if [ "$IJK_FFMPEG_REPO_URL" != "" ]; then
IJK_FFMPEG_UPSTREAM=$IJK_FFMPEG_REPO_URL
IJK_FFMPEG_FORK=$IJK_FFMPEG_REPO_URL
fi
if [ "$IJK_GASP_REPO_URL" != "" ]; then
IJK_GASP_UPSTREAM=$IJK_GASP_REPO_URL
fi
判断是否配置了IJK_FFMPEG_REPO_URL (ffmpeg的地址)
判断是否配置了IJK_GASP_REPO_URL(汇编工具地址)
set -e
TOOLS=tools
你写的每个脚本都应该在文件开头加上set -e,这句语句告诉bash如果任何语句的执行结果不是true则应该退出。
FF_ALL_ARCHS_IOS6_SDK="armv7 armv7s i386"
FF_ALL_ARCHS_IOS7_SDK="armv7 armv7s arm64 i386 x86_64"
FF_ALL_ARCHS_IOS8_SDK="armv7 arm64 i386 x86_64"
FF_ALL_ARCHS=$FF_ALL_ARCHS_IOS8_SDK
定义ios的不同sdk对应的不通结构体.这里默认使用的是ios8的结构体
FF_TARGET=$1
获取传入进来的第一个参数
function echo_ffmpeg_version() {
echo $IJK_FFMPEG_COMMIT
}
该函数获取打印版本
function pull_common() {
git --version
echo "== pull gas-preprocessor base =="
sh $TOOLS/pull-repo-base.sh $IJK_GASP_UPSTREAM extra/gas-preprocessor
echo "== pull ffmpeg base =="
sh $TOOLS/pull-repo-base.sh $IJK_FFMPEG_UPSTREAM $IJK_FFMPEG_LOCAL_REPO
}
该函数就是下载gas-preprocessor 到extra/gas-preprocessor中
下载ffmpeg 到extra/ffmpeg 中
function pull_fork() {
echo "== pull ffmpeg fork $1 =="
sh $TOOLS/pull-repo-ref.sh $IJK_FFMPEG_FORK ios/ffmpeg-$1 ${IJK_FFMPEG_LOCAL_REPO}
cd ios/ffmpeg-$1
git checkout ${IJK_FFMPEG_COMMIT} -B ijkplayer
cd -
}
执行脚本 tools/pull-repo-ref.sh
function pull_fork_all() {
for ARCH in $FF_ALL_ARCHS
do
pull_fork $ARCH
done
}
依次遍历所有的结构体
function sync_ff_version() {
sed -i '' "s/static const char \*kIJKFFRequiredFFmpegVersion\ \=\ .*/static const char *kIJKFFRequiredFFmpegVersion = \"${IJK_FFMPEG_COMMIT}\";/g" ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m
}
Linux sed 命令是利用脚本来处理文本文件。
-i :直接修改读取的文件内容,而不是输出到终端。
举例 sed -i 's/原字符串/新字符串/g' /home/1.txt
该命令就是修改文件,增加版本号
#----------
case "$FF_TARGET" in
ffmpeg-version)
echo_ffmpeg_version
;;
armv7|armv7s|arm64|i386|x86_64)
pull_common
pull_fork $FF_TARGET
;;
all|*)
pull_common
pull_fork_all
;;
esac
这里就是命令选择了.
1.要是我们在脚本传入的参数是 ffmpeg-version 就调用echo_ffmpeg_version
2.要是我们传入的是arch ,那么我们就编译特定的结构体
3.其他的就执行pull_common 和pull_fork_all 命令
sync_ff_version
最后修改文件版本
pull-repo-base.sh
#! /usr/bin/env bash
REMOTE_REPO=$1
LOCAL_WORKSPACE=$2
if [ -z $REMOTE_REPO -o -z $LOCAL_WORKSPACE ]; then
echo "invalid call pull-repo.sh '$REMOTE_REPO' '$LOCAL_WORKSPACE'"
elif [ ! -d $LOCAL_WORKSPACE ]; then
git clone $REMOTE_REPO $LOCAL_WORKSPACE
else
cd $LOCAL_WORKSPACE
git fetch --all --tags
cd -
fi
-z 判断 变量的值,是否为空; zero = 0
&& 并且 || 或 -a 并且 -o 或者
-d filename 如果 filename为目录,则为真
该脚本就是下载文件用的.该脚本需要两个参数
REMOTE_REPO 指向第一个参数,指向的远程的git仓库
LOCAL_WORKSPACE 指向的是下载到本地目录
1.只要参数少一个,打印使用规则
- 要是下载到文件路径不存在就 将远程仓库下载到指定文件夹下
- 要是下载的路径存在,说明已经下载过了,那么就更新仓库所有的tag
该文件就是主要用来下载 git源码文件的
pull-repo-ref.sh
REMOTE_REPO=$1
LOCAL_WORKSPACE=$2
REF_REPO=$3
if [ -z $1 -o -z $2 -o -z $3 ]; then
echo "invalid call pull-repo.sh '$1' '$2' '$3'"
elif [ ! -d $LOCAL_WORKSPACE ]; then
git clone --reference $REF_REPO $REMOTE_REPO $LOCAL_WORKSPACE
cd $LOCAL_WORKSPACE
git repack -a
else
cd $LOCAL_WORKSPACE
git fetch --all --tags
cd -
fi
1判断是否输入三个参数.没有打印该文件使用
2 判断第二个参数指定的文件夹是否存在.不存在.进行相关git操作.
3.存在进行相关git操作
这里我们知道外界传入的参数是
2 = ios/ffmpeg-armv7 或者 ios/ffmpeg-arm64 等
$3 = extra/ffmpeg
通过脚本分析,我们知道.init-ios.sh 文件就是做了下准备工作下载相关git源码和在指定文件目录下创建相关git仓库
compile-ffmpeg.sh
真正编译是在该脚本中
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Bilibili
# Copyright (C) 2013-2014 Zhang Rui <bbcallen@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#----------
# modify for your build tool
FF_ALL_ARCHS_IOS6_SDK="armv7 armv7s i386"
FF_ALL_ARCHS_IOS7_SDK="armv7 armv7s arm64 i386 x86_64"
FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"
FF_ALL_ARCHS=$FF_ALL_ARCHS_IOS8_SDK
#----------
UNI_BUILD_ROOT=`pwd`
UNI_TMP="$UNI_BUILD_ROOT/tmp"
UNI_TMP_LLVM_VER_FILE="$UNI_TMP/llvm.ver.txt"
FF_TARGET=$1
FF_TARGET_EXTRA=$2
set -e
#----------
echo_archs() {
echo "===================="
echo "[*] check xcode version"
echo "===================="
echo "FF_ALL_ARCHS = $FF_ALL_ARCHS"
}
FF_LIBS="libavcodec libavfilter libavformat libavutil libswscale libswresample"
do_lipo_ffmpeg () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/ffmpeg-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done
xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
}
SSL_LIBS="libcrypto libssl"
do_lipo_ssl () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/openssl-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done
if [ "$LIPO_FLAGS" != "" ]; then
xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
fi
}
do_lipo_all () {
mkdir -p $UNI_BUILD_ROOT/build/universal/lib
echo "lipo archs: $FF_ALL_ARCHS"
for FF_LIB in $FF_LIBS
do
do_lipo_ffmpeg "$FF_LIB.a";
done
ANY_ARCH=
for ARCH in $FF_ALL_ARCHS
do
ARCH_INC_DIR="$UNI_BUILD_ROOT/build/ffmpeg-$ARCH/output/include"
if [ -d "$ARCH_INC_DIR" ]; then
if [ -z "$ANY_ARCH" ]; then
ANY_ARCH=$ARCH
cp -R "$ARCH_INC_DIR" "$UNI_BUILD_ROOT/build/universal/"
fi
UNI_INC_DIR="$UNI_BUILD_ROOT/build/universal/include"
mkdir -p "$UNI_INC_DIR/libavutil/$ARCH"
cp -f "$ARCH_INC_DIR/libavutil/avconfig.h" "$UNI_INC_DIR/libavutil/$ARCH/avconfig.h"
cp -f tools/avconfig.h "$UNI_INC_DIR/libavutil/avconfig.h"
cp -f "$ARCH_INC_DIR/libavutil/ffversion.h" "$UNI_INC_DIR/libavutil/$ARCH/ffversion.h"
cp -f tools/ffversion.h "$UNI_INC_DIR/libavutil/ffversion.h"
mkdir -p "$UNI_INC_DIR/libffmpeg/$ARCH"
cp -f "$ARCH_INC_DIR/libffmpeg/config.h" "$UNI_INC_DIR/libffmpeg/$ARCH/config.h"
cp -f tools/config.h "$UNI_INC_DIR/libffmpeg/config.h"
fi
done
for SSL_LIB in $SSL_LIBS
do
do_lipo_ssl "$SSL_LIB.a";
done
}
#----------
if [ "$FF_TARGET" = "armv7" -o "$FF_TARGET" = "armv7s" -o "$FF_TARGET" = "arm64" ]; then
echo_archs
sh tools/do-compile-ffmpeg.sh $FF_TARGET $FF_TARGET_EXTRA
do_lipo_all
elif [ "$FF_TARGET" = "i386" -o "$FF_TARGET" = "x86_64" ]; then
echo_archs
sh tools/do-compile-ffmpeg.sh $FF_TARGET $FF_TARGET_EXTRA
do_lipo_all
elif [ "$FF_TARGET" = "lipo" ]; then
echo_archs
do_lipo_all
elif [ "$FF_TARGET" = "all" ]; then
echo_archs
for ARCH in $FF_ALL_ARCHS
do
sh tools/do-compile-ffmpeg.sh $ARCH $FF_TARGET_EXTRA
done
do_lipo_all
elif [ "$FF_TARGET" = "check" ]; then
echo_archs
elif [ "$FF_TARGET" = "clean" ]; then
echo_archs
echo "=================="
for ARCH in $FF_ALL_ARCHS
do
echo "clean ffmpeg-$ARCH"
echo "=================="
cd ffmpeg-$ARCH && git clean -xdf && cd -
done
echo "clean build cache"
echo "================="
rm -rf build/ffmpeg-*
rm -rf build/openssl-*
rm -rf build/universal/include
rm -rf build/universal/lib
echo "clean success"
else
echo "Usage:"
echo " compile-ffmpeg.sh armv7|arm64|i386|x86_64"
echo " compile-ffmpeg.sh armv7s (obselete)"
echo " compile-ffmpeg.sh lipo"
echo " compile-ffmpeg.sh all"
echo " compile-ffmpeg.sh clean"
echo " compile-ffmpeg.sh check"
exit 1
fi
下面我们就开始分析上面的脚本
FF_ALL_ARCHS_IOS6_SDK="armv7 armv7s i386"
FF_ALL_ARCHS_IOS7_SDK="armv7 armv7s arm64 i386 x86_64"
FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"
FF_ALL_ARCHS=$FF_ALL_ARCHS_IOS8_SDK
设置所需要编译的结构体
UNI_BUILD_ROOT=`pwd`
UNI_TMP="$UNI_BUILD_ROOT/tmp"
UNI_TMP_LLVM_VER_FILE="$UNI_TMP/llvm.ver.txt"
FF_TARGET=$1
FF_TARGET_EXTRA=$2
set -e
设置文件路径变量 和外界传入的参数变量
echo_archs() {
echo "===================="
echo "[*] check xcode version"
echo "===================="
echo "FF_ALL_ARCHS = $FF_ALL_ARCHS"
}
该函数的作用就是打印所有的需要编译的结构体
FF_LIBS="libavcodec libavfilter libavformat libavutil libswscale libswresample"
需要编译库的名字
do_lipo_ffmpeg () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/ffmpeg-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done
xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
}
看着命名就是合并编译完成的结构体
LIB_FILE 代表的是传入的需要lipo的库名字
LIPO_FLAGS 记录查询到的需要lipo合并的 库的路径
SSL_LIBS="libcrypto libssl"
do_lipo_ssl () {
LIB_FILE=$1
LIPO_FLAGS=
for ARCH in $FF_ALL_ARCHS
do
ARCH_LIB_FILE="$UNI_BUILD_ROOT/build/openssl-$ARCH/output/lib/$LIB_FILE"
if [ -f "$ARCH_LIB_FILE" ]; then
LIPO_FLAGS="$LIPO_FLAGS $ARCH_LIB_FILE"
else
echo "skip $LIB_FILE of $ARCH";
fi
done
if [ "$LIPO_FLAGS" != "" ]; then
xcrun lipo -create $LIPO_FLAGS -output $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
xcrun lipo -info $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE
fi
}
同理执行lipo命令对ssl库
do_lipo_all () {
mkdir -p $UNI_BUILD_ROOT/build/universal/lib
echo "lipo archs: $FF_ALL_ARCHS"
for FF_LIB in $FF_LIBS
do
do_lipo_ffmpeg "$FF_LIB.a";
done
ANY_ARCH=
for ARCH in $FF_ALL_ARCHS
do
ARCH_INC_DIR="$UNI_BUILD_ROOT/build/ffmpeg-$ARCH/output/include"
if [ -d "$ARCH_INC_DIR" ]; then
if [ -z "$ANY_ARCH" ]; then
ANY_ARCH=$ARCH
cp -R "$ARCH_INC_DIR" "$UNI_BUILD_ROOT/build/universal/"
fi
UNI_INC_DIR="$UNI_BUILD_ROOT/build/universal/include"
mkdir -p "$UNI_INC_DIR/libavutil/$ARCH"
cp -f "$ARCH_INC_DIR/libavutil/avconfig.h" "$UNI_INC_DIR/libavutil/$ARCH/avconfig.h"
cp -f tools/avconfig.h "$UNI_INC_DIR/libavutil/avconfig.h"
cp -f "$ARCH_INC_DIR/libavutil/ffversion.h" "$UNI_INC_DIR/libavutil/$ARCH/ffversion.h"
cp -f tools/ffversion.h "$UNI_INC_DIR/libavutil/ffversion.h"
mkdir -p "$UNI_INC_DIR/libffmpeg/$ARCH"
cp -f "$ARCH_INC_DIR/libffmpeg/config.h" "$UNI_INC_DIR/libffmpeg/$ARCH/config.h"
cp -f tools/config.h "$UNI_INC_DIR/libffmpeg/config.h"
fi
done
for SSL_LIB in $SSL_LIBS
do
do_lipo_ssl "$SSL_LIB.a";
done
该函数的作用lipo 所有ffmeng编译好的库,可能是原来的写法很难看,因此这里改进了下.
我感觉还是
xcrun lipo -create
find \$UNI_BUILD_ROOT/build -name $LIB_FILE
-output $UNI_BUILD_ROOT/build/universal/lib/$LIB_FILE || exit 1
接着就是头文件处理
if [ "$FF_TARGET" = "armv7" -o "$FF_TARGET" = "armv7s" -o "$FF_TARGET" = "arm64" ]; then
echo_archs
sh tools/do-compile-ffmpeg.sh $FF_TARGET $FF_TARGET_EXTRA
do_lipo_all
elif [ "$FF_TARGET" = "i386" -o "$FF_TARGET" = "x86_64" ]; then
echo_archs
sh tools/do-compile-ffmpeg.sh $FF_TARGET $FF_TARGET_EXTRA
do_lipo_all
elif [ "$FF_TARGET" = "lipo" ]; then
echo_archs
do_lipo_all
elif [ "$FF_TARGET" = "all" ]; then
echo_archs
for ARCH in $FF_ALL_ARCHS
do
sh tools/do-compile-ffmpeg.sh $ARCH $FF_TARGET_EXTRA
done
do_lipo_all
elif [ "$FF_TARGET" = "check" ]; then
echo_archs
elif [ "$FF_TARGET" = "clean" ]; then
echo_archs
echo "=================="
for ARCH in $FF_ALL_ARCHS
do
echo "clean ffmpeg-$ARCH"
echo "=================="
cd ffmpeg-$ARCH && git clean -xdf && cd -
done
echo "clean build cache"
echo "================="
rm -rf build/ffmpeg-*
rm -rf build/openssl-*
rm -rf build/universal/include
rm -rf build/universal/lib
echo "clean success"
else
echo "Usage:"
echo " compile-ffmpeg.sh armv7|arm64|i386|x86_64"
echo " compile-ffmpeg.sh armv7s (obselete)"
echo " compile-ffmpeg.sh lipo"
echo " compile-ffmpeg.sh all"
echo " compile-ffmpeg.sh clean"
echo " compile-ffmpeg.sh check"
exit 1
fi
下面就是命令选择了
armv7 arvm7s arm64 i386 x86_64 这些命令需要运行脚本do-compile-ffmpeg.sh
lipo 命令
all 命令 是编译所有的结构体
check命令
clean命令
compile-ffmpeg.sh
这个脚本是真正编译的脚本了
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Bilibili
# Copyright (C) 2013-2014 Zhang Rui <bbcallen@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script is based on projects below
# https://github.com/kolyvan/kxmovie
# https://github.com/yixia/FFmpeg-Android
# http://git.videolan.org/?p=vlc-ports/android.git;a=summary
# https://github.com/kewlbear/FFmpeg-iOS-build-script/
#--------------------
echo "===================="
echo "[*] check host"
echo "===================="
set -e
#--------------------
# include
#--------------------
# common defines
FF_ARCH=$1
FF_BUILD_OPT=$2
echo "FF_ARCH=$FF_ARCH"
echo "FF_BUILD_OPT=$FF_BUILD_OPT"
if [ -z "$FF_ARCH" ]; then
echo "You must specific an architecture 'armv7, armv7s, arm64, i386, x86_64, ...'.\n"
exit 1
fi
FF_BUILD_ROOT=`pwd`
FF_TAGET_OS="darwin"
# ffmpeg build params
export COMMON_FF_CFG_FLAGS=
source $FF_BUILD_ROOT/../config/module.sh
FFMPEG_CFG_FLAGS=
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $COMMON_FF_CFG_FLAGS"
# Optimization options (experts only):
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-armv5te"
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-armv6"
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-armv6t2"
# Advanced options (experts only):
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-cross-compile"
# --disable-symver may indicate a bug
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-symver"
# Developer options (useful when working on FFmpeg itself):
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-stripping"
##
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --arch=$FF_ARCH"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --target-os=$FF_TAGET_OS"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-static"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-shared"
FFMPEG_EXTRA_CFLAGS=
# i386, x86_64
FFMPEG_CFG_FLAGS_SIMULATOR=
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-asm"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-mmx"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --assert-level=2"
# armv7, armv7s, arm64
FFMPEG_CFG_FLAGS_ARM=
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-pic"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-neon"
case "$FF_BUILD_OPT" in
debug)
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-optimizations"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-small"
;;
*)
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-optimizations"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-small"
;;
esac
echo "build_root: $FF_BUILD_ROOT"
#--------------------
echo "===================="
echo "[*] check gas-preprocessor"
echo "===================="
FF_TOOLS_ROOT="$FF_BUILD_ROOT/../extra"
export PATH="$FF_TOOLS_ROOT/gas-preprocessor:$PATH"
echo "gasp: $FF_TOOLS_ROOT/gas-preprocessor/gas-preprocessor.pl"
#--------------------
echo "===================="
echo "[*] config arch $FF_ARCH"
echo "===================="
FF_BUILD_NAME="unknown"
FF_XCRUN_PLATFORM="iPhoneOS"
FF_XCRUN_OSVERSION=
FF_GASPP_EXPORT=
FF_DEP_OPENSSL_INC=
FF_DEP_OPENSSL_LIB=
FF_XCODE_BITCODE=
if [ "$FF_ARCH" = "i386" ]; then
FF_BUILD_NAME="ffmpeg-i386"
FF_BUILD_NAME_OPENSSL=openssl-i386
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="-mios-simulator-version-min=6.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "x86_64" ]; then
FF_BUILD_NAME="ffmpeg-x86_64"
FF_BUILD_NAME_OPENSSL=openssl-x86_64
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="-mios-simulator-version-min=7.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "armv7" ]; then
FF_BUILD_NAME="ffmpeg-armv7"
FF_BUILD_NAME_OPENSSL=openssl-armv7
FF_XCRUN_OSVERSION="-miphoneos-version-min=6.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
# FFMPEG_CFG_CPU="--cpu=cortex-a8"
elif [ "$FF_ARCH" = "armv7s" ]; then
FF_BUILD_NAME="ffmpeg-armv7s"
FF_BUILD_NAME_OPENSSL=openssl-armv7s
FFMPEG_CFG_CPU="--cpu=swift"
FF_XCRUN_OSVERSION="-miphoneos-version-min=6.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
elif [ "$FF_ARCH" = "arm64" ]; then
FF_BUILD_NAME="ffmpeg-arm64"
FF_BUILD_NAME_OPENSSL=openssl-arm64
FF_XCRUN_OSVERSION="-miphoneos-version-min=7.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
FF_GASPP_EXPORT="GASPP_FIX_XCODE5=1"
else
echo "unknown architecture $FF_ARCH";
exit 1
fi
echo "build_name: $FF_BUILD_NAME"
echo "platform: $FF_XCRUN_PLATFORM"
echo "osversion: $FF_XCRUN_OSVERSION"
#--------------------
echo "===================="
echo "[*] make ios toolchain $FF_BUILD_NAME"
echo "===================="
FF_BUILD_SOURCE="$FF_BUILD_ROOT/$FF_BUILD_NAME"
FF_BUILD_PREFIX="$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --prefix=$FF_BUILD_PREFIX"
mkdir -p $FF_BUILD_PREFIX
echo "build_source: $FF_BUILD_SOURCE"
echo "build_prefix: $FF_BUILD_PREFIX"
#--------------------
echo "\n--------------------"
echo "[*] configurate ffmpeg"
echo "--------------------"
FF_XCRUN_SDK=`echo $FF_XCRUN_PLATFORM | tr '[:upper:]' '[:lower:]'`
FF_XCRUN_CC="xcrun -sdk $FF_XCRUN_SDK clang"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_CPU"
FFMPEG_CFLAGS=
FFMPEG_CFLAGS="$FFMPEG_CFLAGS -arch $FF_ARCH"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FF_XCRUN_OSVERSION"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FFMPEG_EXTRA_CFLAGS"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FF_XCODE_BITCODE"
FFMPEG_LDFLAGS="$FFMPEG_CFLAGS"
FFMPEG_DEP_LIBS=
#--------------------
echo "\n--------------------"
echo "[*] check OpenSSL"
echo "----------------------"
FFMPEG_DEP_OPENSSL_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/include
FFMPEG_DEP_OPENSSL_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/lib
#--------------------
# with openssl
if [ -f "${FFMPEG_DEP_OPENSSL_LIB}/libssl.a" ]; then
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-openssl"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS -I${FFMPEG_DEP_OPENSSL_INC}"
FFMPEG_DEP_LIBS="$FFMPEG_CFLAGS -L${FFMPEG_DEP_OPENSSL_LIB} -lssl -lcrypto"
fi
#--------------------
echo "\n--------------------"
echo "[*] configure"
echo "----------------------"
if [ ! -d $FF_BUILD_SOURCE ]; then
echo ""
echo "!! ERROR"
echo "!! Can not find FFmpeg directory for $FF_BUILD_NAME"
echo "!! Run 'sh init-ios.sh' first"
echo ""
exit 1
fi
# xcode configuration
export DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
cd $FF_BUILD_SOURCE
if [ -f "./config.h" ]; then
echo 'reuse configure'
else
echo "config: $FFMPEG_CFG_FLAGS $FF_XCRUN_CC"
./configure \
$FFMPEG_CFG_FLAGS \
--cc="$FF_XCRUN_CC" \
$FFMPEG_CFG_CPU \
--extra-cflags="$FFMPEG_CFLAGS" \
--extra-cxxflags="$FFMPEG_CFLAGS" \
--extra-ldflags="$FFMPEG_LDFLAGS $FFMPEG_DEP_LIBS"
make clean
fi
#--------------------
echo "\n--------------------"
echo "[*] compile ffmpeg"
echo "--------------------"
cp config.* $FF_BUILD_PREFIX
make -j3 $FF_GASPP_EXPORT
make install
mkdir -p $FF_BUILD_PREFIX/include/libffmpeg
cp -f config.h $FF_BUILD_PREFIX/include/libffmpeg/config.h
分段分析
echo "[*] check host"
echo "===================="
set -e
打印信息和设置脚本属性,只要发生错误就退出
FF_ARCH=$1
FF_BUILD_OPT=$2
echo "FF_ARCH=$FF_ARCH"
echo "FF_BUILD_OPT=$FF_BUILD_OPT"
获取外界传入的参数并打印
这里我们需要知道FF_BUILD_OPT是可选参数($2是可选参数)
if [ -z "$FF_ARCH" ]; then
echo "You must specific an architecture 'armv7, armv7s, arm64, i386, x86_64, ...'.\n"
exit 1
fi
要是$1 没有,那么脚本使用错误,那么打印使用脚本信息退出
FF_BUILD_ROOT=`pwd`
FF_TAGET_OS="darwin"
记录当前目录和 编译的target变量
export COMMON_FF_CFG_FLAGS=
source $FF_BUILD_ROOT/../config/module.sh
FFMPEG_CFG_FLAGS=
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $COMMON_FF_CFG_FLAGS"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-cross-compile"
# --disable-symver may indicate a bug
# FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-symver"
# Developer options (useful when working on FFmpeg itself):
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-stripping"
##
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --arch=$FF_ARCH"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --target-os=$FF_TAGET_OS"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-static"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --disable-shared"
这里就是设置变量
export 是声明一个全局变量,其他脚本也可以访问到该变量
source $FF_BUILD_ROOT/../config/module.sh 就是设置COMMON_FF_CFG_FLAGS变量的值. (当前路径是在/ijkplayer-ios/ios. 因此FF_BUILD_ROOT/../config/module.sh中的module.sh 是在路径/ijkplayer-ios/config/module.sh)
FFMPEG_EXTRA_CFLAGS=
该参数没设置值,在该脚本没有用,这个是预留参数,供我们自己选择添加的参数
FFMPEG_CFG_FLAGS_SIMULATOR=
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-asm"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --disable-mmx"
FFMPEG_CFG_FLAGS_SIMULATOR="$FFMPEG_CFG_FLAGS_SIMULATOR --assert-level=2"
# armv7, armv7s, arm64
FFMPEG_CFG_FLAGS_ARM=
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-pic"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-neon"
设置模拟器和真机的参数
case "$FF_BUILD_OPT" in
debug)
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-optimizations"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --disable-small"
;;
*)
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-optimizations"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-debug"
FFMPEG_CFG_FLAGS_ARM="$FFMPEG_CFG_FLAGS_ARM --enable-small"
;;
esac
FF_BUILD_OPT 是我们传入脚本的第二个参数,只有一个值可选debug
echo "build_root: $FF_BUILD_ROOT"
#--------------------
echo "===================="
echo "[*] check gas-preprocessor"
echo "===================="
打印相关参数
FF_TOOLS_ROOT="$FF_BUILD_ROOT/../extra"
该参数指向的目录是 //ijkplayer-ios/extra
export PATH="$FF_TOOLS_ROOT/gas-preprocessor:$PATH"
echo "gasp: $FF_TOOLS_ROOT/gas-preprocessor/gas-preprocessor.pl"
给PATH添加路径gas-preprocessor路径,并打印
#--------------------
echo "===================="
echo "[*] config arch $FF_ARCH"
echo "===================="
打印信息
FF_BUILD_NAME="unknown"
FF_XCRUN_PLATFORM="iPhoneOS"
FF_XCRUN_OSVERSION=
FF_GASPP_EXPORT=
FF_DEP_OPENSSL_INC=
FF_DEP_OPENSSL_LIB=
FF_XCODE_BITCODE=
声明相关变量
if [ "$FF_ARCH" = "i386" ]; then
FF_BUILD_NAME="ffmpeg-i386"
FF_BUILD_NAME_OPENSSL=openssl-i386
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="-mios-simulator-version-min=6.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "x86_64" ]; then
FF_BUILD_NAME="ffmpeg-x86_64"
FF_BUILD_NAME_OPENSSL=openssl-x86_64
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="-mios-simulator-version-min=7.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "armv7" ]; then
FF_BUILD_NAME="ffmpeg-armv7"
FF_BUILD_NAME_OPENSSL=openssl-armv7
FF_XCRUN_OSVERSION="-miphoneos-version-min=6.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
# FFMPEG_CFG_CPU="--cpu=cortex-a8"
elif [ "$FF_ARCH" = "armv7s" ]; then
FF_BUILD_NAME="ffmpeg-armv7s"
FF_BUILD_NAME_OPENSSL=openssl-armv7s
FFMPEG_CFG_CPU="--cpu=swift"
FF_XCRUN_OSVERSION="-miphoneos-version-min=6.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
elif [ "$FF_ARCH" = "arm64" ]; then
FF_BUILD_NAME="ffmpeg-arm64"
FF_BUILD_NAME_OPENSSL=openssl-arm64
FF_XCRUN_OSVERSION="-miphoneos-version-min=7.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
FF_GASPP_EXPORT="GASPP_FIX_XCODE5=1"
else
echo "unknown architecture $FF_ARCH";
exit 1
fi
根据不同的结构体编译给相关变量赋值
echo "build_name: $FF_BUILD_NAME"
echo "platform: $FF_XCRUN_PLATFORM"
echo "osversion: $FF_XCRUN_OSVERSION"
#--------------------
echo "===================="
echo "[*] make ios toolchain $FF_BUILD_NAME"
echo "===================="
打印相关信息
FF_BUILD_SOURCE="$FF_BUILD_ROOT/$FF_BUILD_NAME"
FF_BUILD_PREFIX="$FF_BUILD_ROOT/build/$FF_BUILD_NAME/output"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --prefix=$FF_BUILD_PREFIX"
声明变量
FF_BUILD_SOURCE =/ijkplayer-ios/ios/ ffmpeg-i386 (编译源码地址)
FF_BUILD_PREFIX = /ijkplayer-ios/ios/build/ ffmpeg-i386/output (编译结果输出地址)
mkdir -p $FF_BUILD_PREFIX
echo "build_source: $FF_BUILD_SOURCE"
echo "build_prefix: $FF_BUILD_PREFIX"
创建输出文件路径文件夹并打印信息
#--------------------
echo "\n--------------------"
echo "[*] configurate ffmpeg"
echo "--------------------"
FF_XCRUN_SDK=`echo $FF_XCRUN_PLATFORM | tr '[:upper:]' '[:lower:]'`
FF_XCRUN_CC="xcrun -sdk $FF_XCRUN_SDK clang"
赋值相关变量
FF_XCRUN_SDK = iPhonesimulator
FF_XCRUN_CC = xcrun -sdk iPhonesimulator clang
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_CPU"
添加cpu相关编译参数
FFMPEG_CFLAGS=
FFMPEG_CFLAGS="$FFMPEG_CFLAGS -arch $FF_ARCH"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FF_XCRUN_OSVERSION"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FFMPEG_EXTRA_CFLAGS"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS $FF_XCODE_BITCODE"
FFMPEG_LDFLAGS="$FFMPEG_CFLAGS"
FFMPEG_DEP_LIBS=
声明参数
#--------------------
echo "\n--------------------"
echo "[*] check OpenSSL"
echo "----------------------"
FFMPEG_DEP_OPENSSL_INC=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/include
FFMPEG_DEP_OPENSSL_LIB=$FF_BUILD_ROOT/build/$FF_BUILD_NAME_OPENSSL/output/lib
#--------------------
# with openssl
if [ -f "${FFMPEG_DEP_OPENSSL_LIB}/libssl.a" ]; then
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS --enable-openssl"
FFMPEG_CFLAGS="$FFMPEG_CFLAGS -I${FFMPEG_DEP_OPENSSL_INC}"
FFMPEG_DEP_LIBS="$FFMPEG_CFLAGS -L${FFMPEG_DEP_OPENSSL_LIB} -lssl -lcrypto"
fi
openssl相关设置.这里没有用因此相当于无效.
echo "\n--------------------"
echo "[*] configure"
echo "----------------------"
if [ ! -d $FF_BUILD_SOURCE ]; then
echo ""
echo "!! ERROR"
echo "!! Can not find FFmpeg directory for $FF_BUILD_NAME"
echo "!! Run 'sh init-ios.sh' first"
echo ""
exit 1
fi
检查编译源是否存在,不存在就退出
# xcode configuration
export DEBUG_INFORMATION_FORMAT=dwarf-with-dsym
Xcode 配置
cd $FF_BUILD_SOURCE
if [ -f "./config.h" ]; then
echo 'reuse configure'
else
echo "config: $FFMPEG_CFG_FLAGS $FF_XCRUN_CC"
./configure \
$FFMPEG_CFG_FLAGS \
--cc="$FF_XCRUN_CC" \
$FFMPEG_CFG_CPU \
--extra-cflags="$FFMPEG_CFLAGS" \
--extra-cxxflags="$FFMPEG_CFLAGS" \
--extra-ldflags="$FFMPEG_LDFLAGS $FFMPEG_DEP_LIBS"
make clean
fi
1.进入源码目录
2.是否存在config.h 文件-f filename 如果 filename为常规文件,则为真 [ -f /usr/bin/grep ]
- 打印参数,并启用编译命令
这里我们需要知道c文件编译需要经过 ./configure make 和make install三部曲.不做解释
我们看看编译命令的各个参数的值
FFMPEG_CFG_FLAGS = --disable-gpl --disable-nonfree --enable-runtime-cpudetect --disable-gray --disable-swscale-alpha --disable-programs --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-avdevice --enable-avcodec --enable-avformat --enable-avutil --enable-swresample --enable-swscale --disable-postproc --enable-avfilter --disable-avresample --enable-network --disable-d3d11va --disable-dxva2 --disable-vaapi --disable-vda --disable-vdpau --disable-videotoolbox --disable-encoders --enable-encoder=png --disable-decoders --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=flv --enable-decoder=h264 --enable-decoder=mp3* --enable-decoder=vp6f --enable-decoder=flac --enable-decoder=hevc --enable-decoder=vp8 --enable-decoder=vp9 --disable-hwaccels --disable-muxers --enable-muxer=mp4 --disable-demuxers --enable-demuxer=aac --enable-demuxer=concat --enable-demuxer=data --enable-demuxer=flv --enable-demuxer=hls --enable-demuxer=live_flv --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=mpegps --enable-demuxer=mpegts --enable-demuxer=mpegvideo --enable-demuxer=flac --enable-demuxer=hevc --enable-demuxer=webm_dash_manifest --disable-parsers --enable-parser=aac --enable-parser=aac_latm --enable-parser=h264 --enable-parser=flac --enable-parser=hevc --enable-bsfs --disable-bsf=chomp --disable-bsf=dca_core --disable-bsf=dump_extradata --disable-bsf=hevc_mp4toannexb --disable-bsf=imx_dump_header --disable-bsf=mjpeg2jpeg --disable-bsf=mjpega_dump_header --disable-bsf=mov2textsub --disable-bsf=mp3_header_decompress --disable-bsf=mpeg4_unpack_bframes --disable-bsf=noise --disable-bsf=remove_extradata --disable-bsf=text2movsub --disable-bsf=vp9_superframe --enable-protocols --enable-protocol=async --disable-protocol=bluray --disable-protocol=concat --disable-protocol=crypto --disable-protocol=ffrtmpcrypt --enable-protocol=ffrtmphttp --disable-protocol=gopher --disable-protocol=icecast --disable-protocol=librtmp* --disable-protocol=libssh --disable-protocol=md5 --disable-protocol=mmsh --disable-protocol=mmst --disable-protocol=rtmp* --enable-protocol=rtmp --enable-protocol=rtmpt --disable-protocol=rtp --disable-protocol=sctp --disable-protocol=srtp --disable-protocol=subfile --disable-protocol=unix --disable-devices --disable-filters --disable-iconv --disable-audiotoolbox --disable-videotoolbox --disable-linux-perf --disable-bzlib --enable-cross-compile --disable-stripping --arch=arm64 --target-os=darwin --enable-static --disable-shared --enable-pic --enable-neon --enable-optimizations --enable-debug --enable-small --prefix=/Users/glodon/Desktop/vidio/ijk/ijkplayer-ios/ios/build/ffmpeg-arm64/output
FFMPEG_CFG_CPU =
FFMPEG_CFLAGS = -arch arm64 -miphoneos-version-min=7.0 -fembed-bitcode
FFMPEG_CFLAGS = -arch arm64 -miphoneos-version-min=7.0 -fembed-bitcode
FFMPEG_LDFLAGS FFMPEG_DEP_LIBS = -arch arm64 -miphoneos-version-min=7.0 -fembed-bitcode
#--------------------
echo "\n--------------------"
echo "[*] compile ffmpeg"
echo "--------------------"
打印相关信息
cp config.* $FF_BUILD_PREFIX
copy相关信息到指定目录
make -j3 $FF_GASPP_EXPORT
make install
完成三部曲
mkdir -p $FF_BUILD_PREFIX/include/libffmpeg
创建目录
cp -f config.h $FF_BUILD_PREFIX/include/libffmpeg/config.h
将配置信息copy到指定位置