From 2cc802ff780e6b71559bb934904d851ea90c00d7 Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Fri, 24 Oct 2025 12:06:46 -0500 Subject: [PATCH] fix how encode versioning is found and stored --- lib/build.sh | 9 ++++++--- lib/encode.sh | 27 +++++++++++++++++++++++++-- lib/utils.sh | 5 +++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/build.sh b/lib/build.sh index 6eeb0cd..f0d1aee 100644 --- a/lib/build.sh +++ b/lib/build.sh @@ -789,7 +789,10 @@ build_libnuma() { add_project_versioning_to_ffmpeg() { # embed this project's enables/versions # into ffmpeg with FFMPEG_BUILDER_INFO - local FFMPEG_BUILDER_INFO=("ffmpeg-builder=$(git -C "${REPO_DIR}" rev-parse HEAD)") + local FFMPEG_BUILDER_INFO=( + '' # pad with empty line + "ffmpeg-builder=$(git -C "${REPO_DIR}" rev-parse HEAD)" + ) for build in ${ENABLE}; do get_build_conf "${build}" || return 1 # add build configuration info @@ -799,13 +802,13 @@ add_project_versioning_to_ffmpeg() { get_build_conf ffmpeg || return 1 FFMPEG_BUILDER_INFO+=("${build}=${ver}") - local fname='ffmpeg_opt.c' + local fname='opt_common.c' local optFile="fftools/${fname}" if [[ ! -f ${optFile} ]]; then echo_fail "could not find ${fname} to add project versioning" fi - local searchFor='Universal media converter\n' + local searchFor='static void print_all_libs_info' local foundUsageStart=0 local newOptFile="${TMP_DIR}/${fname}" test -f "${newOptFile}" && rm "${newOptFile}" diff --git a/lib/encode.sh b/lib/encode.sh index 451600c..08a7010 100644 --- a/lib/encode.sh +++ b/lib/encode.sh @@ -80,7 +80,7 @@ get_encode_versions() { audioEncVersion='' # shellcheck disable=SC2155 - local output="$(ffmpeg -hide_banner 2>&1)" + local output="$(ffmpeg -version 2>&1)" while read -r line; do if line_contains "${line}" 'ffmpeg='; then ffmpegVersion="${line}" @@ -91,6 +91,29 @@ get_encode_versions() { fi done <<<"${output}" + local version + if [[ ${ffmpegVersion} == '' ]]; then + while read -r line; do + if line_starts_with "${line}" 'ffmpeg version '; then + read -r _ _ version _ <<<"${line}" + ffmpegVersion="ffmpeg=${version}" + break + fi + done <<<"${output}" + fi + + if [[ ${videoEncVersion} == '' ]]; then + version="$(get_pkgconfig_version SvtAv1Enc)" + test "${version}" == '' && return 1 + videoEncVersion="libsvtav1=${version}" + fi + + if [[ ${audioEncVersion} == '' ]]; then + version="$(get_pkgconfig_version opus)" + test "${version}" == '' && return 1 + audioEncVersion="libopus=${version}" + fi + test "${ffmpegVersion}" == '' && return 1 test "${videoEncVersion}" == '' && return 1 test "${audioEncVersion}" == '' && return 1 @@ -166,7 +189,7 @@ set_encode_opts() { ;; v) get_encode_versions print - exit 0 + exit $? ;; i) if [[ $# -lt 2 ]]; then diff --git a/lib/utils.sh b/lib/utils.sh index b9122c1..f7a32fb 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -297,3 +297,8 @@ spinner() { done done } + +get_pkgconfig_version() { + local pkg="$1" + pkg-config --modversion "${pkg}" +} \ No newline at end of file