mirror of
git://code.qt.io/qt/qt5.git
synced 2026-02-01 19:36:04 +08:00
Add ffmpeg-installation-utils.sh file
There're code duplications in install-ffmpeg scripts.
Let's have a file with FFmpeg installation utils and reuse
the functionality on unix platforms.
The utility functions make the code more robust and get
around code duplications.
This cherry-pick had a minor merge conflict because a patch
for switching arm64-simulator to x86_64-simulator was
merged before this patch. This cherry-oick was updated to
work with this change correctly.
Pick-to: 6.8 6.5
Change-Id: I28639d18c7110109e52ff09ce602da52f8857281
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
(cherry picked from commit 51dad84914)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
committed by
Nils Petter Skålerud
parent
910069f72d
commit
6d7ce3ee6e
67
coin/provisioning/common/unix/ffmpeg-installation-utils.sh
Executable file
67
coin/provisioning/common/unix/ffmpeg-installation-utils.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
download_ffmpeg() {
|
||||
local version="${1:-n7.1}"
|
||||
local sha1="${2:-f008a93710a7577e3f85a90f4b632cc615164712}"
|
||||
|
||||
local ffmpeg_name="FFmpeg-$version"
|
||||
local target_dir="$HOME"
|
||||
local ffmpeg_source_dir="$target_dir/$ffmpeg_name"
|
||||
|
||||
if [ ! -d "$ffmpeg_source_dir" ]; then
|
||||
local url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz"
|
||||
local url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/$version.tar.gz"
|
||||
local app_prefix=""
|
||||
|
||||
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
|
||||
InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix" > /dev/null
|
||||
fi
|
||||
|
||||
echo "$ffmpeg_source_dir"
|
||||
}
|
||||
|
||||
get_ffmpeg_config_options() {
|
||||
local build_type="$1"
|
||||
local result
|
||||
|
||||
result=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt")
|
||||
|
||||
if [ "$build_type" != "static" ]; then
|
||||
result+=" --enable-shared --disable-static"
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
|
||||
get_ffmpeg_build_type() {
|
||||
local result="${1:-shared}"
|
||||
|
||||
if [ "$result" != "static" ] && [ "$result" != "shared" ]; then
|
||||
>&2 echo "Invalid build_type: $result. The shared build type will be used."
|
||||
result="shared"
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
set_ffmpeg_dir_env_var() {
|
||||
local envvar="$1"
|
||||
local dir="$2"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
>&2 echo "the FFmpeg dir $dir doesn't exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# minimal validity check, more checks can be added
|
||||
if [ ! -d "$dir/include" ] || [ ! -d "$dir/lib" ]; then
|
||||
>&2 echo "The FFmpeg dir $dir is not valid"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh"
|
||||
SetEnvVar "$envvar" "$dir"
|
||||
}
|
||||
@@ -4,33 +4,18 @@
|
||||
|
||||
# This script will build and install FFmpeg shared libs
|
||||
set -ex
|
||||
|
||||
source "${BASH_SOURCE%/*}/../unix/ffmpeg-installation-utils.sh"
|
||||
|
||||
os="$1"
|
||||
|
||||
# shellcheck source=../unix/InstallFromCompressedFileFromURL.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
|
||||
# shellcheck source=../unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh"
|
||||
|
||||
version="n7.1"
|
||||
url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz"
|
||||
sha1="f008a93710a7577e3f85a90f4b632cc615164712"
|
||||
url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/$version.tar.gz"
|
||||
ffmpeg_name="FFmpeg-$version"
|
||||
|
||||
build_type=$(get_ffmpeg_build_type)
|
||||
target_dir="$HOME"
|
||||
app_prefix=""
|
||||
ffmpeg_source_dir="$target_dir/$ffmpeg_name"
|
||||
|
||||
if [ ! -d "$ffmpeg_source_dir" ];
|
||||
then
|
||||
InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix"
|
||||
fi
|
||||
ffmpeg_source_dir=$(download_ffmpeg)
|
||||
|
||||
build_ffmpeg_android() {
|
||||
|
||||
target_arch=$1
|
||||
target_dir=$2
|
||||
shared="${3:-no}"
|
||||
|
||||
sudo mkdir -p "$target_dir"
|
||||
|
||||
@@ -77,11 +62,8 @@ build_ffmpeg_android() {
|
||||
ar=${toolchain_bin}/llvm-ar
|
||||
ranlib=${toolchain_bin}/llvm-ranlib
|
||||
|
||||
ffmpeg_config_options=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt")
|
||||
ffmpeg_config_options=$(get_ffmpeg_config_options $build_type)
|
||||
ffmpeg_config_options+=" --enable-cross-compile --target-os=android --enable-jni --enable-mediacodec --enable-openssl --enable-pthreads --enable-neon --disable-asm --disable-indev=android_camera"
|
||||
if [[ "$shared" == "yes" ]]; then
|
||||
ffmpeg_config_options+=" --enable-shared --disable-static"
|
||||
fi
|
||||
ffmpeg_config_options+=" --arch=$target_arch --cpu=${target_cpu} --sysroot=${sysroot} --sysinclude=${sysroot}/usr/include/"
|
||||
ffmpeg_config_options+=" --cc=${cc} --cxx=${cxx} --ar=${ar} --ranlib=${ranlib}"
|
||||
ffmpeg_config_options+=" --extra-cflags=-I${openssl_include} --extra-ldflags=-L${openssl_libs}"
|
||||
@@ -100,7 +82,7 @@ build_ffmpeg_android() {
|
||||
rm -f "${openssl_libs}/libcrypto.so"
|
||||
rm -f "${openssl_libs}/libssl.so"
|
||||
|
||||
if [[ "$shared" == "yes" ]]; then
|
||||
if [[ "$build_type" == "shared" ]]; then
|
||||
fix_dependencies="${BASH_SOURCE%/*}/../shared/fix_ffmpeg_dependencies.sh"
|
||||
sudo "${fix_dependencies}" "${target_dir}" "${libs_prefix}" "no"
|
||||
fi
|
||||
@@ -109,18 +91,16 @@ build_ffmpeg_android() {
|
||||
if [ "$os" == "android-x86" ]; then
|
||||
target_arch=x86
|
||||
target_dir="/usr/local/android/ffmpeg-x86"
|
||||
|
||||
SetEnvVar "FFMPEG_DIR_ANDROID_X86" "$target_dir"
|
||||
envvar="FFMPEG_DIR_ANDROID_X86"
|
||||
elif [ "$os" == "android-x86_64" ]; then
|
||||
target_arch=x86_64
|
||||
target_dir="/usr/local/android/ffmpeg-x86_64"
|
||||
|
||||
SetEnvVar "FFMPEG_DIR_ANDROID_X86_64" "$target_dir"
|
||||
envvar="FFMPEG_DIR_ANDROID_X86_64"
|
||||
elif [ "$os" == "android-arm64" ]; then
|
||||
target_arch=arm64
|
||||
target_dir="/usr/local/android/ffmpeg-arm64"
|
||||
|
||||
SetEnvVar "FFMPEG_DIR_ANDROID_ARM64" "$target_dir"
|
||||
envvar="FFMPEG_DIR_ANDROID_ARM64"
|
||||
fi
|
||||
|
||||
build_ffmpeg_android "$target_arch" "$target_dir" "yes"
|
||||
build_ffmpeg_android "$target_arch" "$target_dir"
|
||||
set_ffmpeg_dir_env_var "$envvar" "$target_dir"
|
||||
|
||||
@@ -5,29 +5,13 @@
|
||||
# This script will build and install FFmpeg static libs
|
||||
set -ex
|
||||
|
||||
# shellcheck source=../unix/InstallFromCompressedFileFromURL.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
|
||||
# shellcheck source=../unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh"
|
||||
source "${BASH_SOURCE%/*}/../unix/ffmpeg-installation-utils.sh"
|
||||
|
||||
version="n7.1"
|
||||
url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz"
|
||||
sha1="f008a93710a7577e3f85a90f4b632cc615164712"
|
||||
url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/$version.tar.gz"
|
||||
ffmpeg_name="FFmpeg-$version"
|
||||
|
||||
target_dir="$HOME"
|
||||
ffmpeg_source_dir="$target_dir/$ffmpeg_name"
|
||||
ffmpeg_source_dir=$(download_ffmpeg)
|
||||
ffmpeg_config_options=$(get_ffmpeg_config_options "shared")
|
||||
prefix="/usr/local/ios/ffmpeg"
|
||||
dylib_regex="^@rpath/.*\.dylib$"
|
||||
|
||||
if [ ! -d "$ffmpeg_source_dir" ];
|
||||
then
|
||||
InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir"
|
||||
fi
|
||||
|
||||
ffmpeg_config_options=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt")
|
||||
|
||||
build_ffmpeg_ios() {
|
||||
local target_platform=$1
|
||||
local target_cpu_arch=""
|
||||
@@ -202,6 +186,6 @@ for name in $ffmpeg_libs; do
|
||||
create_xcframework $name "arm64-iphoneos" "x86_64-simulator"
|
||||
done
|
||||
|
||||
install_ffmpeg "$ffmpeg_source_dir/build_ios/arm64-iphoneos/installed"
|
||||
install_ffmpeg "$ffmpeg_source_dir/build_ios/x86_64-simulator/installed" "$ffmpeg_source_dir/build_ios/arm64-iphoneos/installed"
|
||||
|
||||
SetEnvVar "FFMPEG_DIR_IOS" $prefix
|
||||
set_ffmpeg_dir_env_var "FFMPEG_DIR_IOS" $prefix
|
||||
|
||||
@@ -4,48 +4,27 @@
|
||||
|
||||
# This script will build and install FFmpeg static libs
|
||||
set -ex
|
||||
|
||||
source "${BASH_SOURCE%/*}/../unix/ffmpeg-installation-utils.sh"
|
||||
|
||||
os="$1"
|
||||
build_type="$2"
|
||||
build_type=$(get_ffmpeg_build_type "$2")
|
||||
|
||||
if [ ! -n "$build_type" ] && [ "$build_type" != "static" ] && [ "$build_type" != "shared" ]; then
|
||||
>&2 echo "Invalid build_type: $build_type. The shared build type will be used."
|
||||
build_type="shared"
|
||||
fi
|
||||
|
||||
# shellcheck source=../unix/InstallFromCompressedFileFromURL.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
|
||||
# shellcheck source=../unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../unix/SetEnvVar.sh"
|
||||
|
||||
version="n7.1"
|
||||
url_public="https://github.com/FFmpeg/FFmpeg/archive/refs/tags/$version.tar.gz"
|
||||
sha1="f008a93710a7577e3f85a90f4b632cc615164712"
|
||||
url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/$version.tar.gz"
|
||||
ffmpeg_name="FFmpeg-$version"
|
||||
|
||||
target_dir="$HOME"
|
||||
app_prefix=""
|
||||
ffmpeg_source_dir="$target_dir/$ffmpeg_name"
|
||||
|
||||
if [ ! -d "$ffmpeg_source_dir" ]
|
||||
then
|
||||
InstallFromCompressedFileFromURL "$url_cached" "$url_public" "$sha1" "$target_dir" "$app_prefix"
|
||||
fi
|
||||
|
||||
ffmpeg_config_options=$(cat "${BASH_SOURCE%/*}/../shared/ffmpeg_config_options.txt")
|
||||
if [ "$build_type" != "static" ]; then
|
||||
ffmpeg_config_options+=" --enable-shared --disable-static"
|
||||
fi
|
||||
ffmpeg_source_dir=$(download_ffmpeg)
|
||||
ffmpeg_name=$(basename $ffmpeg_source_dir)
|
||||
ffmpeg_config_options=$(get_ffmpeg_config_options $build_type)
|
||||
|
||||
install_ff_nvcodec_headers() {
|
||||
nv_codec_version="11.1" # use 11.1 to ensure compatibility with 470 nvidia drivers; might be upated to 12.0
|
||||
nv_codec_url_public="https://github.com/FFmpeg/nv-codec-headers/archive/refs/heads/sdk/$nv_codec_version.zip"
|
||||
nv_codec_url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/nv-codec-headers/nv-codec-headers-sdk-$nv_codec_version.zip"
|
||||
nv_codec_sha1="ceb4966ab01b2e41f02074675a8ac5b331bf603e"
|
||||
local nv_codec_version="11.1" # use 11.1 to ensure compatibility with 470 nvidia drivers; might be upated to 12.0
|
||||
local nv_codec_url_public="https://github.com/FFmpeg/nv-codec-headers/archive/refs/heads/sdk/$nv_codec_version.zip"
|
||||
local nv_codec_url_cached="http://ci-files01-hki.ci.qt.io/input/ffmpeg/nv-codec-headers/nv-codec-headers-sdk-$nv_codec_version.zip"
|
||||
local nv_codec_sha1="ceb4966ab01b2e41f02074675a8ac5b331bf603e"
|
||||
#nv_codec_sha1="4f30539f8dd31945da4c3da32e66022f9ca59c08" // 12.0
|
||||
nv_codec_dir="$target_dir/nv-codec-headers-sdk-$nv_codec_version"
|
||||
if [ ! -d "$nv_codec_dir" ]
|
||||
then
|
||||
local target_dir="$HOME"
|
||||
local nv_codec_dir="$target_dir/nv-codec-headers-sdk-$nv_codec_version"
|
||||
|
||||
if [ ! -d "$nv_codec_dir" ]; then
|
||||
source "${BASH_SOURCE%/*}/../unix/InstallFromCompressedFileFromURL.sh"
|
||||
InstallFromCompressedFileFromURL "$nv_codec_url_cached" "$nv_codec_url_public" "$nv_codec_sha1" "$target_dir" ""
|
||||
fi
|
||||
|
||||
@@ -119,13 +98,12 @@ if [ "$os" == "linux" ]; then
|
||||
|
||||
output_dir="$ffmpeg_source_dir/build/installed/usr/local/$ffmpeg_name"
|
||||
|
||||
if [ "$build_type" != "static" ]; then
|
||||
if [ "$build_type" == "shared" ]; then
|
||||
fix_dependencies="${BASH_SOURCE%/*}/../shared/fix_ffmpeg_dependencies.sh"
|
||||
"$fix_dependencies" "$output_dir"
|
||||
fi
|
||||
|
||||
sudo mv "$output_dir" "/usr/local"
|
||||
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
|
||||
|
||||
elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
|
||||
brew install yasm
|
||||
@@ -149,8 +127,7 @@ elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
|
||||
|
||||
sudo "${BASH_SOURCE%/*}/../macos/makeuniversal.sh" "$arm64_install_dir" "$x86_64_install_dir"
|
||||
fi
|
||||
|
||||
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
|
||||
fi
|
||||
|
||||
set_ffmpeg_dir_env_var "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user