#!/bin/bash
set -eu -o pipefail
set +eu +o pipefail
FFMPEG_TAG=n4.5-dev
build_path=$1
git_repo="https://github.com/FFmpeg/FFmpeg.git"
cache_tool=""
sysroot=""
c_compiler="gcc"
cxx_compiler="g++"
ffmpeg_dir=""
build_only=false
parallel="-j$(nproc)"
usage="Usage: $0 [FFMPEG_TAG [build_path [git_repo [cache_tool]]]] [Options]
Options:
FFMPEG_TAG FFMPEG git tag. (default $FFMPEG_TAG)
build_path Target folder to build. (default $(pwd))
git_repo Link of FFmpeg.git. (default $git_repo)
[-c ]cache_tool ccache or sccache
-S sysroot sysroot
-C c-compiler c compiler
-X cxx-compier cxx compiler
-F ECFLAGS add ECFLAGS to CFLAGS []
-s ffmpeg_dir ffmpeg_dir cloned.
-j parallel make -j parallel default is $(nproc)
-b build only
exp:
1. $0 $FFMPEG_TAG $(pwd) $git_repo ccache
2. $0 $FFMPEG_TAG -c ccache
"
for _ff in FFMPEG_TAG build_path git_repo cache_tool; do
if [ "${1::1}" = "-" ]; then
break
else
eval $_ff="$1"
shift
fi
done
while getopts ':hc:C:X:S:bs:j:' opt; do
case "$opt" in
b)
build_only=true
;;
c)
cache_tool="$OPTARG "
;;
C)
c_compiler="$OPTARG"
;;
X)
cxx_compiler="$OPTARG"
;;
S)
sysroot="--sysroot=$OPTARG"
;;
s)
ffmpeg_dir=$(realpath $OPTARG)
;;
j)
if [ "$OPTARG" -eq "$OPTARG" ]; then
parallel="-j $OPTARG"
else
echo "$OPTARG should be a number, use '$parallel' by default"
fi
;;
? | h)
echo "$usage"
exit 1
;;
esac
done
src_path=$(dirname $(readlink -f $0))
echo "src path: ${src_path}"
echo "build path: ${build_path}"
echo "ffmpeg path: ${ffmpeg_dir}"
if [ -z $ffmpeg_dir ]; then
echo "delete old FFmpeg files"
rm -rf ${build_path}/FFmpeg-${FFMPEG_TAG}
rm -rf ${build_path}/ffmpeg_gcu
echo "download FFmpeg-${FFMPEG_TAG}"
git clone -b ${FFMPEG_TAG} $git_repo ${build_path}/FFmpeg-${FFMPEG_TAG}
ffmpeg_dir=${build_path}/FFmpeg-${FFMPEG_TAG}
elif ! [ -d $ffmpeg_dir ]; then
echo "FFmpeg need to be cloned to $ffmpeg_dir"
exit 1
fi
echo "copy FFmpeg GCU Plugin files info FFmpeg source tree"
cd $ffmpeg_dir
cp ${src_path}/src/configure ${ffmpeg_dir}/
cp ${src_path}/src/libavformat/* ${ffmpeg_dir}/libavformat/
cp ${src_path}/src/libavcodec/* ${ffmpeg_dir}/libavcodec/
cp ${src_path}/src/libavutil/* ${ffmpeg_dir}/libavutil/
cp ${src_path}/src/examples/* ${ffmpeg_dir}/doc/examples/
echo "configure FFmpeg"
./configure
--prefix=${build_path}/ffmpeg_gcu
--extra-cflags="-g"
--extra-ldflags="-fuse-ld=gold"
--extra-ldflags="-m64 -lefrt -lefdrv -ltopsrt -ltopscodec -ldl -lpthread"
--disable-stripping
--disable-x86asm
--enable-swscale
--disable-decoders
--disable-optimizations
--enable-topscodec
--enable-decoder=vc1
--enable-decoder=av1
--enable-decoder=h264
--enable-decoder=hevc
--enable-decoder=vp8
--enable-decoder=vp9
--enable-decoder=mpeg4
--enable-decoder=mpeg2video
--enable-decoder=mjpeg
--enable-decoder=h264_topscodec
--enable-decoder=hevc_topscodec
--enable-decoder=mpeg2_topscodec
--enable-decoder=mpeg4_topscodec
--enable-decoder=h263_topscodec
--enable-decoder=vc1_topscodec
--enable-decoder=vp8_topscodec
--enable-decoder=vp9_topscodec
--enable-decoder=avs_topscodec
--enable-decoder=avs2_topscodec
--enable-decoder=mjpeg_topscodec
--enable-decoder=av1_topscodec
--cc="${cache_tool}$c_compiler"
--cxx="${cache_tool}$cxx_compiler"
$sysroot
--enable-cross-compile
--disable-static
--enable-shared
if [ $? -ne 0 ]; then
echo "configure failed"
exit 1
fi
make clean
echo "make"
make $parallel
if [ $? -ne 0 ]; then
echo "make failed"
exit 1
fi
echo "make examples"
make examples -j
if [ $? -ne 0 ]; then
echo "make examples failed"
exit 1
fi
if $build_only; then
exit 0
fi
echo "make install"
make install
if [ $? -ne 0 ]; then
echo "make install failed"
exit 1
fi
cp ${ffmpeg_dir}/doc/examples/hw_decode_tops ${build_path}/ffmpeg_gcu/bin
cp ${ffmpeg_dir}/doc/examples/decode_tops ${build_path}/ffmpeg_gcu/bin
原文地址:https://blog.csdn.net/weixin_43360707/article/details/134597661
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_14825.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。