Compare commits

...
12 Commits
Author SHA1 Message Date
levogevo c49901597c bump ffmpeg 8.1.1 -> 8.1.2 2026-07-13 15:13:01 -05:00
levogevo b1afb83db4 update efg to use print_opt_map 2026-05-31 16:40:27 -05:00
levogevo 4e1aac1284 generate encode usage programatically 2026-05-31 12:20:49 -05:00
levogevo 14249e814b bump versions 2026-05-27 17:46:48 -05:00
levogevo ddf2fa103c bump svtav1_hdr to 4.1.0 2026-05-02 14:56:58 -05:00
levogevo 9962071250 update get_crop install install_deps 2026-04-25 20:44:59 -05:00
levogevo 0e436efc3f update README 2026-04-03 20:31:26 -05:00
levogevo 63f674e95a update readme and warning 2026-03-29 11:26:02 -05:00
levogevo e2441ea693 libjxl tools depend on libwebp 2026-03-28 21:29:03 -05:00
levogevo 7db4289f0e fix libsnappy with PGO 2026-03-28 14:08:19 -05:00
levogevo 8597ca6088 add libsnappy/lcms2 to enable and reformat BUILDS_CONF 2026-03-27 20:44:06 -05:00
levogevo 4092e0f215 turn DEBUG off for Jenkinsfile by default 2026-03-27 17:50:07 -05:00
12 changed files with 454 additions and 275 deletions
+12
View File
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
Vendored
+1 -1
View File
@@ -14,7 +14,7 @@ def withDockerCreds(body) {
pipeline {
agent none
environment {
DEBUG = "1"
DEBUG = "0"
HEADLESS = "1"
}
options { buildDiscarder logRotator(numToKeepStr: '4') }
+35 -10
View File
@@ -24,14 +24,39 @@ Configuration is done through environment variables.
By default, this project will build a static `ffmpeg` binary in `./gitignore/sysroot/bin/ffmpeg`.
The user-overridable compile options are:
- `ENABLE`: configure what ffmpeg enables (default: libaom libass libvpx libxml2 libvmaf libx264 libx265 libwebp libopus librav1e libdav1d libvorbis libmp3lame libfribidi libfreetype libharfbuzz libopenjpeg libsvtav1_hdr libfontconfig )
- `PREFIX`: prefix to install to, default is local install in ./gitignore/sysroot (default: local)
- `STATIC`: static or shared build (default: ON)
- `LTO`: enable link time optimization (default: ON)
- `CLEAN`: clean build directories before building (default: ON)
- `PGO`: enable profile guided optimization (default: OFF)
- `ARCH`: architecture type (x86-64-v{1,2,3,4}, armv8-a, etc) (default: native)
- `OPT`: optimization level (0-3) (default: 3)
- `ENABLE`: configure what ffmpeg enables. default:
lcms2
libaom
libass
libvpx
libjxl
libxml2
libvmaf
libx264
libx265
libwebp
libopus
librav1e
libdav1d
libbluray
libsnappy
libvorbis
libmp3lame
libfribidi
libfreetype
libharfbuzz
libopenjpeg
libsvtav1_hdr
libfontconfig
- `PREFIX`: path to install to, local install is in ./gitignore/sysroot. default: local
- `STATIC`: static (ON) or shared (OFF) build. default: ON
- `LTO`: enable link time optimization (ON/OFF). default: ON
- `CLEAN`: clean build directories before building (ON/OFF). default: ON
- `PGO`: enable profile guided optimization (ON/OFF). default: OFF
- `PACKAGE`: package ffmpeg binaries to tarball in ./gitignore/package (ON/OFF). default: OFF
- `ARCH`: architecture type (x86-64-v{1,2,3,4}, armv8-a, etc). default: native
- `OPT`: optimization level (0-3). default: 3
Examples:
- only build libsvtav1_psy and libopus: `ENABLE='libsvtav1_psy libopus' ./scripts/build.sh`
@@ -55,7 +80,7 @@ ENABLE='libdav1d' ./scripts/docker_run_image.sh ubuntu ./scripts/build.sh
# Encoding scripts
The encoding scripts are designed to be installed to system paths for re-use via symbolic links back to this repo using the `-I` flag.
## Encoding with svtav1-psy and opus
## Encoding with svtav1 and opus
```bash
encode -i input [options] output
[-P NUM] set preset (default: 3)
@@ -73,7 +98,7 @@ encode -i input [options] output
[-I] system install at /usr/local/bin/encode
[-U] uninstall from /usr/local/bin/encode
```
- Uses svtav1-psy for the video encoder.
- Uses svtav1 for the video encoder.
- Uses libopus for the audio encoder.
- Skips re-encoding av1/opus streams.
- Only maps audio streams that match the video stream language if the video stream has a defined language.
+104 -1
View File
@@ -27,7 +27,7 @@ echo_wrapper() {
echo -e "${args[@]}" "${color}${word:-''}${endColor}" "$@"
}
echo_fail() { color="${RED}" word="FAIL" echo_wrapper "$@"; }
echo_fail() { color="${RED}" word="FAIL" echo_wrapper "$@" 1>&2; }
echo_info() { color="${CYAN}" word="INFO" echo_wrapper "$@"; }
echo_pass() { color="${GREEN}" word="PASS" echo_wrapper "$@"; }
echo_warn() { color="${YELLOW}" word="WARN" echo_wrapper "$@"; }
@@ -420,6 +420,25 @@ using_cmake3() {
line_starts_with "${cmakeVersion}" 3
}
get_cmake_flag() {
local findFlag="$1"
shift
local flags=("$@")
local flagOption
for flag in "${flags[@]}"; do
if line_starts_with "${flag}" "-D${findFlag}="; then
IFS='=' read -r _ flagOption <<<"${flag}"
fi
done
if [[ -z ${flagOption} ]]; then
echo_fail "could not find ${findFlag} from ${flags[*]}"
return 1
else
echo "${flagOption}"
fi
}
have_req_meson_version() {
local min=1.6.1
have_required_version "$(meson --version)" "${min}"
@@ -549,3 +568,87 @@ check_for_supmover() {
SUPMOVER="${LOCAL_PREFIX}/bin/supmover"
test -f "${SUPMOVER}" || do_build supmover || return 1
}
repeat_character() {
local char="$1"
local count="$2"
local spaces
printf -v spaces "%${count}s" ''
echo "${spaces// /${char}}"
}
# read given varnames to set:
# - index array
# - short option array
# - long option array
# - option description array with
# padding based off of longest option
parse_opt_map() {
local optIndexVarname="$1"
local shortOptVarname="$2"
local longOptVarname="$3"
local descOptVarname="$4"
shift 4
local optMap=("$@")
declare -n optIndex="${optIndexVarname}"
declare -n shortOpt="${shortOptVarname}"
declare -n longOpt="${longOptVarname}"
declare -n descOpt="${descOptVarname}"
local opt index short long desc
local longestOpt=0
for opt in "${optMap[@]}"; do
read -r short long desc <<<"${opt}"
# check for duplicate/overwrites
if line_contains "${shortOpt[*]}" "${short}"; then
echo_fail "${short} already defined"
return 1
fi
if line_contains "${longOpt[*]}" "${long}"; then
echo_fail "${long} already defined"
return 1
fi
# --flag -> flag
index="${long//--/}"
optIndex+=("${index}")
shortOpt["${index}"]="${short}"
longOpt["${index}"]="${long}"
descOpt["${index}"]="${desc}"
# track longest longOpt to pad the description
if [[ ${longestOpt} -lt ${#long} ]]; then
longestOpt=${#long}
fi
done
local longLen
local tab=$'\t\t'
for ind in "${optIndex[@]}"; do
long="${longOpt[${ind}]}"
longLen=${#long}
padding="$(repeat_character ' ' $((longestOpt - longLen)))"
descOpt["${ind}"]="${padding}${tab}${descOpt[${ind}]}"
done
}
print_opt_map() {
local optionMap=("$@")
local OPT_INDS
declare -A SHORT_OPTS LONG_OPTS DESC_OPTS
parse_opt_map \
OPT_INDS \
SHORT_OPTS \
LONG_OPTS \
DESC_OPTS \
"${optionMap[@]}" || return 1
echo -e "\nOPTIONS:"
for ind in "${OPT_INDS[@]}"; do
echo -e " ${SHORT_OPTS[${ind}]}, ${LONG_OPTS[${ind}]}${DESC_OPTS[${ind}]}"
done
echo
}
+68 -55
View File
@@ -322,6 +322,8 @@ fi' >"${compilerDir}/which"
echo
}
# BUILDS_CONF intentionally does not expand variables
# shellcheck disable=SC2016
get_build_conf() {
local getBuild="${1}"
local getBuildValue="${2:-}"
@@ -332,68 +334,68 @@ get_build_conf() {
local padding=4
# name version file-extension url dep1,dep2
# shellcheck disable=SC2016
local BUILDS_CONF='
ffmpeg 8.1 tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${ver}.${ext}
libsvtav1_hdr 4.0.1 tar.gz https://github.com/juliobbv-p/svt-av1-hdr/archive/refs/tags/v${ver}.${ext} dovi_tool,hdr10plus_tool,cpuinfo
libsvtav1_psy 3.0.2-B tar.gz https://github.com/BlueSwordM/svt-av1-psyex/archive/refs/tags/v${ver}.${ext} dovi_tool,hdr10plus_tool,cpuinfo
hdr10plus_tool 1.7.2 tar.gz https://github.com/quietvoid/hdr10plus_tool/archive/refs/tags/${ver}.${ext}
dovi_tool 2.3.1 tar.gz https://github.com/quietvoid/dovi_tool/archive/refs/tags/${ver}.${ext}
cpuinfo main git https://github.com/pytorch/cpuinfo/
libsvtav1 4.1.0 tar.gz https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v${ver}/SVT-AV1-v${ver}.${ext}
librav1e 0.8.1 tar.gz https://github.com/xiph/rav1e/archive/refs/tags/v${ver}.${ext}
ffmpeg 8.1.2 tar.gz https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n${ver}.${ext}
'
# ffmpeg --enable packages
BUILDS_CONF+='
lcms2 2.18 tar.gz https://github.com/mm2/Little-CMS/archive/refs/tags/lcms${ver}.${ext} libtiff,libjpeg
libaom 3.13.1 tar.gz https://storage.googleapis.com/aom-releases/libaom-${ver}.${ext}
libvmaf 3.0.0 tar.gz https://github.com/Netflix/vmaf/archive/refs/tags/v${ver}.${ext}
libopus 1.6 tar.gz https://github.com/xiph/opus/archive/refs/tags/v${ver}.${ext}
libdav1d 1.5.3 tar.xz https://downloads.videolan.org/videolan/dav1d/${ver}/dav1d-${ver}.${ext}
libx264 master git https://code.videolan.org/videolan/x264.git
libmp3lame 3.100 tar.gz https://pilotfiber.dl.sourceforge.net/project/lame/lame/${ver}/lame-${ver}.${ext}
libass 0.17.4 tar.xz https://github.com/libass/libass/releases/download/${ver}/libass-${ver}.${ext} libfontconfig,libfreetype,libharfbuzz,libfribidi,libunibreak,libxml2,xz
libvpx 1.16.0 tar.gz https://github.com/webmproject/libvpx/archive/refs/tags/v${ver}.${ext}
libjxl v0.11.2 git https://github.com/libjxl/libjxl brotli,libpng,libwebp
libxml2 2.15.1 tar.gz https://github.com/GNOME/libxml2/archive/refs/tags/v${ver}.${ext}
libvmaf 3.0.0 tar.gz https://github.com/Netflix/vmaf/archive/refs/tags/v${ver}.${ext}
libx264 master git https://code.videolan.org/videolan/x264.git
libx265 4.1 tar.gz http://ftp.videolan.org/pub/videolan/x265/x265_${ver}.${ext} libnuma,cmake3
libwebp 1.6.0 tar.gz https://github.com/webmproject/libwebp/archive/refs/tags/v${ver}.${ext} libpng,libjpeg
libopus 1.6.1 tar.gz https://github.com/xiph/opus/archive/refs/tags/v${ver}.${ext}
librav1e 0.8.1 tar.gz https://github.com/xiph/rav1e/archive/refs/tags/v${ver}.${ext}
libdav1d 1.5.3 tar.xz https://downloads.videolan.org/videolan/dav1d/${ver}/dav1d-${ver}.${ext}
libbluray 1.4.1 tar.xz https://download.videolan.org/pub/videolan/libbluray/${ver}/libbluray-${ver}.${ext} libfontconfig,libfreetype,libxml2
libsnappy 1.2.2 tar.gz https://github.com/google/snappy/archive/refs/tags/${ver}.${ext}
libssh 0.11.1 tar.gz https://github.com/canonical/libssh/archive/refs/tags/libssh-${ver}.${ext} libcrypto
libcrypto 3.6.1 tar.gz https://github.com/openssl/openssl/archive/refs/tags/openssl-${ver}.${ext} brotli,zlib,zstd
libvorbis 1.3.7 tar.xz https://github.com/xiph/vorbis/releases/download/v${ver}/libvorbis-${ver}.${ext} libogg,cmake3
libogg 1.3.6 tar.xz https://github.com/xiph/ogg/releases/download/v${ver}/libogg-${ver}.${ext}
libjxl v0.11.2 git https://github.com/libjxl/libjxl brotli,libpng
libmp3lame 3.100 tar.gz https://pilotfiber.dl.sourceforge.net/project/lame/lame/${ver}/lame-${ver}.${ext}
libfribidi 1.0.16 tar.xz https://github.com/fribidi/fribidi/releases/download/v${ver}/fribidi-${ver}.${ext}
libfreetype 2.14.1 tar.xz https://downloads.sourceforge.net/freetype/freetype-${ver}.${ext} bzip,libpng,zlib,brotli,libharfbuzzNFTP
libharfbuzz 12.3.0 tar.xz https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.${ext} libfreetype
libopenjpeg 2.5.4 tar.gz https://github.com/uclouvain/openjpeg/archive/refs/tags/v${ver}.${ext} libtiff,lcms2
lcms2 2.18 tar.gz https://github.com/mm2/Little-CMS/archive/refs/tags/lcms${ver}.${ext} libtiff,libjpeg
libtiff 4.7.1 tar.gz https://github.com/libsdl-org/libtiff/archive/refs/tags/v${ver}.${ext} libwebp,libdeflate,xz,zstd
libwebp 1.6.0 tar.gz https://github.com/webmproject/libwebp/archive/refs/tags/v${ver}.${ext} libpng,libjpeg
libjpeg 3.0.3 tar.gz https://github.com/winlibs/libjpeg/archive/refs/tags/libjpeg-turbo-${ver}.${ext}
libpng 1.6.53 tar.gz https://github.com/pnggroup/libpng/archive/refs/tags/v${ver}.${ext} zlib
libsvtav1 4.1.0 tar.gz https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v${ver}/SVT-AV1-v${ver}.${ext}
libsvtav1_hdr 4.1.0 tar.gz https://github.com/juliobbv-p/svt-av1-hdr/archive/refs/tags/v${ver}.${ext} dovi_tool,hdr10plus_tool,cpuinfo
libsvtav1_psy 3.0.2-B tar.gz https://github.com/BlueSwordM/svt-av1-psyex/archive/refs/tags/v${ver}.${ext} dovi_tool,hdr10plus_tool,cpuinfo
libfontconfig 2.17.1 tar.xz https://gitlab.freedesktop.org/api/v4/projects/890/packages/generic/fontconfig/${ver}/fontconfig-${ver}.${ext} libharfbuzz,expat,brotli
'
# dependencies
BUILDS_CONF+='
xz 5.8.2 tar.xz https://github.com/tukaani-project/xz/releases/download/v${ver}/xz-${ver}.${ext}
glad 2.0.8 tar.gz https://github.com/Dav1dde/glad/archive/refs/tags/v${ver}.${ext}
zlib 1.3.1 tar.gz https://github.com/madler/zlib/archive/refs/tags/v${ver}.${ext}
libdeflate 1.25 tar.gz https://github.com/ebiggers/libdeflate/archive/refs/tags/v${ver}.${ext} zlib
zstd 1.5.7 tar.gz https://github.com/facebook/zstd/archive/refs/tags/v${ver}.${ext}
libplacebo 7.351.0 tar.gz https://github.com/haasn/libplacebo/archive/refs/tags/v${ver}.${ext} glslang,vulkan_loader,glad
bzip master git https://github.com/libarchive/bzip2.git
expat 2.7.3 tar.xz https://github.com/libexpat/libexpat/releases/download/R_${ver//./_}/expat-${ver}.${ext}
brotli 1.2.0 tar.gz https://github.com/google/brotli/archive/refs/tags/v${ver}.${ext}
cmake3 3.31.8 tar.gz https://github.com/Kitware/CMake/archive/refs/tags/v${ver}.${ext}
libogg 1.3.6 tar.xz https://github.com/xiph/ogg/releases/download/v${ver}/libogg-${ver}.${ext}
libpng 1.6.53 tar.gz https://github.com/pnggroup/libpng/archive/refs/tags/v${ver}.${ext} zlib
libtiff 4.7.1 tar.gz https://github.com/libsdl-org/libtiff/archive/refs/tags/v${ver}.${ext} libwebp,libdeflate,xz,zstd
cpuinfo main git https://github.com/pytorch/cpuinfo/
libjpeg 3.0.3 tar.gz https://github.com/winlibs/libjpeg/archive/refs/tags/libjpeg-turbo-${ver}.${ext}
glslang 16.0.0 tar.gz https://github.com/KhronosGroup/glslang/archive/refs/tags/${ver}.${ext} spirv_tools
libnuma 2.0.19 tar.gz https://github.com/numactl/numactl/archive/refs/tags/v${ver}.${ext}
supmover 2.4.3 tar.gz https://github.com/MonoS/SupMover/archive/refs/tags/v${ver}.${ext}
dovi_tool 2.3.1 tar.gz https://github.com/quietvoid/dovi_tool/archive/refs/tags/${ver}.${ext}
libcrypto 3.6.1 tar.gz https://github.com/openssl/openssl/archive/refs/tags/openssl-${ver}.${ext} brotli,zlib,zstd
libdeflate 1.25 tar.gz https://github.com/ebiggers/libdeflate/archive/refs/tags/v${ver}.${ext} zlib
libunibreak 6.1 tar.gz https://github.com/adah1972/libunibreak/releases/download/libunibreak_${ver//./_}/libunibreak-${ver}.${ext}
spirv_tools 2025.4 tar.gz https://github.com/KhronosGroup/SPIRV-Tools/archive/refs/tags/v${ver}.${ext} spirv_headers
spirv_headers 1.4.328.1 tar.gz https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags/vulkan-sdk-${ver}.${ext}
glad 2.0.8 tar.gz https://github.com/Dav1dde/glad/archive/refs/tags/v${ver}.${ext}
libx265 4.1 tar.gz http://ftp.videolan.org/pub/videolan/x265/x265_${ver}.${ext} libnuma,cmake3
libnuma 2.0.19 tar.gz https://github.com/numactl/numactl/archive/refs/tags/v${ver}.${ext}
cmake3 3.31.8 tar.gz https://github.com/Kitware/CMake/archive/refs/tags/v${ver}.${ext}
libass 0.17.4 tar.xz https://github.com/libass/libass/releases/download/${ver}/libass-${ver}.${ext} libfontconfig,libfreetype,libharfbuzz,libfribidi,libunibreak,libxml2,xz
libfontconfig 2.17.1 tar.xz https://gitlab.freedesktop.org/api/v4/projects/890/packages/generic/fontconfig/${ver}/fontconfig-${ver}.${ext} libharfbuzz,expat,brotli
libfreetype 2.14.1 tar.xz https://downloads.sourceforge.net/freetype/freetype-${ver}.${ext} bzip,libpng,zlib,brotli,libharfbuzzNFTP
hdr10plus_tool 1.7.2 tar.gz https://github.com/quietvoid/hdr10plus_tool/archive/refs/tags/${ver}.${ext}
libharfbuzzNFTP 12.3.0 tar.xz https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.${ext}
libharfbuzz 12.3.0 tar.xz https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.${ext} libfreetype
libunibreak 6.1 tar.gz https://github.com/adah1972/libunibreak/releases/download/libunibreak_${ver//./_}/libunibreak-${ver}.${ext}
libxml2 2.15.1 tar.gz https://github.com/GNOME/libxml2/archive/refs/tags/v${ver}.${ext}
xz 5.8.2 tar.xz https://github.com/tukaani-project/xz/releases/download/v${ver}/xz-${ver}.${ext}
libfribidi 1.0.16 tar.xz https://github.com/fribidi/fribidi/releases/download/v${ver}/fribidi-${ver}.${ext}
bzip master git https://github.com/libarchive/bzip2.git
brotli 1.2.0 tar.gz https://github.com/google/brotli/archive/refs/tags/v${ver}.${ext}
expat 2.7.3 tar.xz https://github.com/libexpat/libexpat/releases/download/R_${ver//./_}/expat-${ver}.${ext}
supmover 2.4.3 tar.gz https://github.com/MonoS/SupMover/archive/refs/tags/v${ver}.${ext}
'
# ffmpeg --enable that are not added to DEFAULT_ENABLE (WIP)
BUILDS_CONF+='
libssh 0.11.1 tar.gz https://github.com/canonical/libssh/archive/refs/tags/libssh-${ver}.${ext} libcrypto
libplacebo 7.351.0 tar.gz https://github.com/haasn/libplacebo/archive/refs/tags/v${ver}.${ext} glslang,vulkan_loader,glad
'
local supported_builds=()
unset ver ext url deps extractedDir
@@ -403,9 +405,11 @@ supmover 2.4.3 tar.gz https://github.com/MonoS/SupMover/archi
supported_builds+=("${build}")
# padding support
longestBuild="$(fb_max "${#build}" "${longestBuild}")"
longestVer="$(fb_max "${#ver}" "${longestVer}")"
longestExt="$(fb_max "${#ext}" "${longestExt}")"
if [[ ${getBuild} == 'formatted' ]]; then
longestBuild="$(fb_max "${#build}" "${longestBuild}")"
longestVer="$(fb_max "${#ver}" "${longestVer}")"
longestExt="$(fb_max "${#ext}" "${longestExt}")"
fi
if [[ ${getBuild} != "${build}" ]]; then
build=''
@@ -701,9 +705,10 @@ build() {
local ffmpeg="$(command -v ffmpeg 2>/dev/null)"
if [[ ${ffmpeg} != "${ffmpegBin}" ]]; then
echo
echo_warn "ffmpeg in path (${ffmpeg}) is not the built one (${ffmpegBin})"
echo_info "consider adding ${BINDIR} to \$PATH"
echo "echo 'export PATH=\"${BINDIR}:\$PATH\"' >> ~/.bashrc"
echo_warn "ffmpeg in PATH (${ffmpeg}) is not the built one (${ffmpegBin})"
local homeAwareBin="${BINDIR//${HOME}/\$HOME}"
echo_info "consider adding ${homeAwareBin} to \$PATH"
echo "echo 'export PATH=\"${homeAwareBin}:\$PATH\"' >> ~/.bashrc"
fi
package || return 1
@@ -1063,7 +1068,15 @@ build_expat() {
}
build_libsnappy() {
local modCxx
modCxx="$(get_cmake_flag CMAKE_CXX_FLAGS "${CMAKE_FLAGS[@]}")" || return 1
if [[ ${PGO} == 'ON' ]]; then
# libsnappy fails PGO for some reason
modCxx+=" -Wno-backend-plugin"
fi
meta_cmake_build \
-DCMAKE_CXX_FLAGS="${modCxx}" \
-DSNAPPY_BUILD_TESTS=OFF \
-DSNAPPY_BUILD_BENCHMARKS=OFF || return 1
sanitize_sysroot_libs libsnappy || return 1
+30 -28
View File
@@ -8,53 +8,55 @@ unset FB_COMP_OPTS_DESC
declare -Ag FB_COMP_OPTS_DESC
# default build options
FB_COMP_OPTS_DESC['CLEAN']='clean build directories before building'
FB_COMP_OPTS_DESC['CLEAN']='clean build directories before building (ON/OFF)'
DEFAULT_CLEAN=ON
FB_COMP_OPTS_DESC['LTO']='enable link time optimization'
FB_COMP_OPTS_DESC['LTO']='enable link time optimization (ON/OFF)'
DEFAULT_LTO=ON
FB_COMP_OPTS_DESC['PGO']='enable profile guided optimization'
FB_COMP_OPTS_DESC['PGO']='enable profile guided optimization (ON/OFF)'
DEFAULT_PGO=OFF
FB_COMP_OPTS_DESC['OPT']='optimization level (0-3)'
DEFAULT_OPT=3
FB_COMP_OPTS_DESC['STATIC']='static or shared build'
FB_COMP_OPTS_DESC['STATIC']='static (ON) or shared (OFF) build'
DEFAULT_STATIC=ON
FB_COMP_OPTS_DESC['ARCH']='architecture type (x86-64-v{1,2,3,4}, armv8-a, etc)'
DEFAULT_ARCH=native
FB_COMP_OPTS_DESC['PREFIX']='prefix to install to, default is local install in ./gitignore/sysroot'
FB_COMP_OPTS_DESC['PREFIX']='path to install to, local install is in ./gitignore/sysroot'
DEFAULT_PREFIX='local'
FB_COMP_OPTS_DESC['PACKAGE']='package ffmpeg binaries to tarball in ./gitignore/package'
FB_COMP_OPTS_DESC['PACKAGE']='package ffmpeg binaries to tarball in ./gitignore/package (ON/OFF)'
DEFAULT_PACKAGE=OFF
FB_COMP_OPTS_DESC['ENABLE']='configure what ffmpeg enables'
DEFAULT_ENABLE="\
libaom \
libass \
libvpx \
libjxl \
libxml2 \
libvmaf \
libx264 \
libx265 \
libwebp \
libopus \
librav1e \
libdav1d \
libbluray \
libvorbis \
libmp3lame \
libfribidi \
libfreetype \
libharfbuzz \
libopenjpeg \
libsvtav1_hdr \
libfontconfig \
DEFAULT_ENABLE="
lcms2
libaom
libass
libvpx
libjxl
libxml2
libvmaf
libx264
libx265
libwebp
libopus
librav1e
libdav1d
libbluray
libsnappy
libvorbis
libmp3lame
libfribidi
libfreetype
libharfbuzz
libopenjpeg
libsvtav1_hdr
libfontconfig
"
# user-overridable compile option variable names
+80 -61
View File
@@ -2,99 +2,114 @@
efg_usage() {
echo "efg -i input [options]"
echo -e "\t[-P NUM] set preset (default: ${PRESET})"
echo -e "\t[-l NUM] low value (default: ${LOW})"
echo -e "\t[-s NUM] step value (default: ${STEP})"
echo -e "\t[-h NUM] high value (default: ${HIGH})"
echo -e "\t[-p] plot bitrates using gnuplot"
echo -e "\n\t[-I] system install at ${EFG_INSTALL_PATH}"
echo -e "\t[-U] uninstall from ${EFG_INSTALL_PATH}"
print_opt_map "${EFG_OPT_MAP[@]}" || return 1
return 0
}
set_efg_opts() {
local opts='P:pl:s:h:i:IU'
local numOpts=${#opts}
# default values
unset INPUT
PRESET=10
LOW=0
STEP=1
HIGH=30
PLOT=false
ENCODE_SEGMENTS=5
EFG_INSTALL_PATH='/usr/local/bin/efg'
local EFG_OPT_MAP=(
"-i --input input file"
"-P --preset set preset (default: ${PRESET})"
"-l --low set low end value for grain range (default: ${LOW})"
"-s --step set step value for grain range (default: ${STEP})"
"-h --high set high end value for grain range (default: ${HIGH})"
"-n --segments number of segments to analyze from input (default: ${ENCODE_SEGMENTS})"
"-p --plot plot bitrates using gnuplot"
"-I --install system install at ${EFG_INSTALL_PATH}"
"-U --uninstall uninstall from ${EFG_INSTALL_PATH}"
)
# only using -I or -U
local minOpt=1
# using all
local maxOpt=${numOpts}
test $# -lt ${minOpt} && efg_usage && return 1
test $# -gt ${maxOpt} && efg_usage && return 1
local OPTARG OPTIND
while getopts "${opts}" flag; do
case "${flag}" in
P)
if ! is_positive_integer "${OPTARG}"; then
local arg value
while [[ $# -gt 0 ]]; do
arg="$1"
value="${2:-}"
case "${arg}" in
-i | --input)
INPUT="${value}"
shift
;;
-P | --preset)
if ! is_positive_integer "${value}"; then
efg_usage
return 1
fi
PRESET="${OPTARG}"
PRESET="${value}"
shift
;;
I)
-l | --low)
if ! is_positive_integer "${value}"; then
efg_usage
return 1
fi
LOW="${value}"
shift
;;
-s | --step)
if ! is_positive_integer "${value}"; then
efg_usage
return 1
fi
STEP="${value}"
shift
;;
-h | --high)
if ! is_positive_integer "${value}"; then
efg_usage
return 1
fi
HIGH="${value}"
shift
;;
-n | --num-segments)
if ! is_positive_integer "${value}"; then
efg_usage
return 1
fi
ENCODE_SEGMENTS="${value}"
shift
;;
-p | --plot)
missing_cmd gnuplot && return 1
PLOT=true
;;
-I | --install)
echo_warn "attempting install"
sudo ln -sf "${SCRIPT_DIR}/efg.sh" \
"${EFG_INSTALL_PATH}" || return 1
echo_pass "succesfull install"
return ${FUNC_EXIT_SUCCESS}
return "${FUNC_EXIT_SUCCESS}"
;;
U)
-U | --uninstall)
echo_warn "attempting uninstall"
sudo rm "${EFG_INSTALL_PATH}" || return 1
echo_pass "succesfull uninstall"
return ${FUNC_EXIT_SUCCESS}
;;
i)
if [[ $# -lt 2 ]]; then
echo_fail "wrong arguments given"
efg_usage
return 1
fi
INPUT="${OPTARG}"
;;
p)
missing_cmd gnuplot && return 1
PLOT=true
;;
l)
if ! is_positive_integer "${OPTARG}"; then
efg_usage
return 1
fi
LOW="${OPTARG}"
;;
s)
if ! is_positive_integer "${OPTARG}"; then
efg_usage
return 1
fi
STEP="${OPTARG}"
;;
h)
if ! is_positive_integer "${OPTARG}"; then
efg_usage
return 1
fi
HIGH="${OPTARG}"
return "${FUNC_EXIT_SUCCESS}"
;;
*)
echo "wrong flags given"
echo_fail "unsupported option: [${arg}]"
efg_usage
return 1
;;
esac
shift
done
if [[ ! -f ${INPUT} ]]; then
echo "${INPUT} does not exist"
# validate input
if [[ -z ${INPUT} || ! -f ${INPUT} ]]; then
echo_fail "input undefined or does not exist"
efg_usage
return 1
fi
@@ -108,7 +123,7 @@ set_efg_opts() {
EFG_DIR+="-${sanitizedInput}"
echo_info "estimating film grain for ${INPUT}"
echo_info "range: $LOW-$HIGH with $STEP step increments"
echo_info "range: ${LOW}-${HIGH} with ${STEP} step increments"
}
efg_segment() {
@@ -255,9 +270,13 @@ FB_FUNC_NAMES+=('efg')
# shellcheck disable=SC2034
FB_FUNC_DESCS['efg']='estimate the film grain of a given file'
efg() {
# localize variables used by child functions
local PRESET LOW STEP HIGH PLOT \
EFG_INSTALL_PATH EFG_DIR ENCODE_SEGMENTS \
GRAIN_LOG
EFG_DIR="${TMP_DIR}/efg"
# encode N highest-bitrate segments
ENCODE_SEGMENTS=5
set_efg_opts "$@"
local ret=$?
+112 -108
View File
@@ -64,7 +64,7 @@ set_subtitle_params() {
local convertCodec='eia_608'
local defaultTextCodec
if [[ ${SAME_CONTAINER} == false && ${FILE_EXT} == 'mkv' ]]; then
if [[ ${SAME_CONTAINER} == false && ${OUTPUT} == *'.mkv' ]]; then
defaultTextCodec='srt'
convertCodec+='|mov_text'
else
@@ -324,19 +324,10 @@ setup_pgs_mkv() {
}
encode_usage() {
echo "encode -i input [options] output"
echo -e "\t[-P NUM] set preset (default: ${PRESET})"
echo -e "\t[-C NUM] set CRF (default: ${CRF})"
echo -e "\t[-g NUM] set film grain for encode"
echo -e "\t[-p] print the command instead of executing it (default: ${PRINT_OUT})"
echo -e "\t[-c] use cropdetect (default: ${CROP})"
echo -e "\t[-d] enable dolby vision (default: ${DV_TOGGLE})"
echo -e "\t[-v] print relevant version info"
echo -e "\t[-s] use same container as input, default is convert to mkv"
echo -e "\n\t[output] if unset, defaults to \${PWD}/av1-input-file-name.mkv"
echo -e "\n\t[-u] update script (git pull ffmpeg-builder)"
echo -e "\t[-I] system install at ${ENCODE_INSTALL_PATH}"
echo -e "\t[-U] uninstall from ${ENCODE_INSTALL_PATH}"
echo "encode -i input [options] [output]"
print_opt_map "${ENCODE_OPT_MAP[@]}" || return 1
echo -e "\n [output] output filename (default: \${PWD}/av1-input-file-name.mkv)\n"
return 0
}
@@ -345,138 +336,146 @@ encode_update() {
}
set_encode_opts() {
local opts='vi:pcsdg:P:C:uIU'
local numOpts=${#opts}
# default values
PRESET=3
CRF=25
GRAIN=""
GRAIN=''
CROP=false
PRINT_OUT=false
DV_TOGGLE=false
ENCODE_INSTALL_PATH='/usr/local/bin/encode'
SAME_CONTAINER="false"
local ENCODE_OPT_MAP=(
"-i --input input file"
"-P --preset set preset (default: ${PRESET})"
"-C --crf set CRF (default: ${CRF})"
"-g --grain set film grain (default: disabled)"
"-p --print print the script instead of executing it"
"-c --crop use crop detect to auto-crop"
"-d --dv enable dolby vision"
"-v --version print version info"
"-s --same-container use same container as input (default: mkv)"
"-u --update update script (git pull ffmpeg-builder)"
"-I --install system install at ${ENCODE_INSTALL_PATH}"
"-U --uninstall uninstall from ${ENCODE_INSTALL_PATH}"
)
# only using -I/U
local minOpt=1
# using all + output name
local maxOpt=$((numOpts + 1))
test $# -lt ${minOpt} && encode_usage && return 1
test $# -gt ${maxOpt} && encode_usage && return 1
local optsUsed=0
local OPTARG OPTIND
while getopts "${opts}" flag; do
case "${flag}" in
u)
encode_update || return 1
return ${FUNC_EXIT_SUCCESS}
local arg value
while [[ $# -gt 0 ]]; do
arg="$1"
value="${2:-}"
case "${arg}" in
-i | --input)
INPUT="${value}"
shift
;;
I)
-P | --preset)
if ! is_positive_integer "${value}"; then
encode_usage
return 1
fi
PRESET="${value}"
shift
;;
-C | --crf)
if ! is_positive_integer "${value}" || test "${value}" -gt 63; then
echo_fail "${value} is not a valid CRF value (0-63)"
encode_usage
return 1
fi
CRF="${value}"
shift
;;
-g | --grain)
if ! is_positive_integer "${value}"; then
encode_usage
return 1
fi
GRAIN="film-grain=${value}:film-grain-denoise=1:adaptive-film-grain=1:"
shift
;;
-c | --crop)
CROP=true
;;
-p | --print)
PRINT_OUT=true
;;
-d | --dv)
DV_TOGGLE=true
;;
-v | --version)
get_encode_versions print || return 1
return "${FUNC_EXIT_SUCCESS}"
;;
-s | --same-container)
SAME_CONTAINER=true
;;
-u | --update)
encode_update || return 1
return "${FUNC_EXIT_SUCCESS}"
;;
-I | --install)
echo_warn "attempting install"
sudo ln -sf "${SCRIPT_DIR}/encode.sh" \
"${ENCODE_INSTALL_PATH}" || return 1
echo_pass "succesfull install"
return ${FUNC_EXIT_SUCCESS}
return "${FUNC_EXIT_SUCCESS}"
;;
U)
-U | --uninstall)
echo_warn "attempting uninstall"
sudo rm "${ENCODE_INSTALL_PATH}" || return 1
echo_pass "succesfull uninstall"
return ${FUNC_EXIT_SUCCESS}
;;
v)
get_encode_versions print || return 1
return ${FUNC_EXIT_SUCCESS}
;;
i)
if [[ $# -lt 2 ]]; then
echo_fail "wrong arguments given"
encode_usage
return 1
fi
INPUT="${OPTARG}"
optsUsed=$((optsUsed + 2))
;;
p)
PRINT_OUT=true
optsUsed=$((optsUsed + 1))
;;
c)
CROP=true
optsUsed=$((optsUsed + 1))
;;
d)
DV_TOGGLE=true
optsUsed=$((optsUsed + 1))
;;
s)
SAME_CONTAINER=true
optsUsed=$((optsUsed + 1))
;;
g)
if ! is_positive_integer "${OPTARG}"; then
encode_usage
return 1
fi
GRAIN="film-grain=${OPTARG}:film-grain-denoise=1:adaptive-film-grain=1:"
optsUsed=$((optsUsed + 2))
;;
P)
if ! is_positive_integer "${OPTARG}"; then
encode_usage
return 1
fi
PRESET="${OPTARG}"
optsUsed=$((optsUsed + 2))
;;
C)
if ! is_positive_integer "${OPTARG}" || test ${OPTARG} -gt 63; then
echo_fail "${OPTARG} is not a valid CRF value (0-63)"
encode_usage
return 1
fi
CRF="${OPTARG}"
OPTS_USED=$((OPTS_USED + 2))
return "${FUNC_EXIT_SUCCESS}"
;;
*)
echo_fail "wrong flags given"
encode_usage
return 1
# OUTPUT will be the last (optional) arg
if [[ $# -ne 1 ]]; then
echo_fail "unsupported option: [${arg}]"
encode_usage
return 1
fi
OUTPUT="${arg}"
;;
esac
shift
done
# allow optional output filename
if [[ $(($# - optsUsed)) == 1 ]]; then
OUTPUT="${*: -1}"
else
local basename="$(bash_basename "${INPUT}")"
# validate input
if [[ -z ${INPUT} || ! -f ${INPUT} ]]; then
echo_fail "input undefined or does not exist"
encode_usage
return 1
fi
# fallback output path
if [[ -z ${OUTPUT} ]]; then
local basename
basename="$(bash_basename "${INPUT}")" || return 1
OUTPUT="${PWD}/av1-${basename}"
fi
# use same container for output
if [[ $SAME_CONTAINER == "true" ]]; then
local fileFormat
if [[ ${SAME_CONTAINER} == true ]]; then
local fileFormat outputSuffix
fileFormat="$(get_file_format "${INPUT}")" || return 1
FILE_EXT=''
if [[ ${fileFormat} == 'MPEG-4' ]]; then
FILE_EXT='mp4'
outputSuffix='mp4'
elif [[ ${fileFormat} == 'Matroska' ]]; then
FILE_EXT='mkv'
outputSuffix='mkv'
else
echo "unrecognized input format"
echo_fail "unrecognized input format"
return 1
fi
else
FILE_EXT="mkv"
outputSuffix='mkv'
fi
OUTPUT="${OUTPUT%.*}"
OUTPUT+=".${FILE_EXT}"
if [[ ! -f ${INPUT} ]]; then
echo "${INPUT} does not exist"
encode_usage
return 1
fi
OUTPUT+=".${outputSuffix}"
if [[ ${PRINT_OUT} == false ]]; then
echo
@@ -658,7 +657,7 @@ gen_encode_script() {
echo 'ffmpeg "${ffmpegParams[@]}" -dolbyvision 0 "${OUTPUT}" || exit 1'
# track-stats and clear title
if [[ ${FILE_EXT} == 'mkv' ]]; then
if [[ ${OUTPUT} == *'.mkv' ]]; then
{
# ffmpeg does not copy PGS subtitles without breaking them
# use mkvmerge to extract and supmover to crop
@@ -690,6 +689,11 @@ FB_FUNC_NAMES+=('encode')
# shellcheck disable=SC2034
FB_FUNC_DESCS['encode']='encode a file using libsvtav1 and libopus'
encode() {
# localize variables used by child functions
local PRESET CRF GRAIN CROP PRINT_OUT \
DV_TOGGLE ENCODE_INSTALL_PATH SAME_CONTAINER \
INPUT OUTPUT
set_encode_opts "$@"
local ret=$?
if [[ ${ret} -eq ${FUNC_EXIT_SUCCESS} ]]; then
+2 -2
View File
@@ -51,8 +51,8 @@ get_crop() {
duration="$(get_duration "${file}")" || return 1
# don't care about decimal points
IFS='.' read -r duration _ <<<"${duration}"
# get crop value for first half of input
local timeEnc=$((duration / 20))
# get crop value for first tenth of input
local timeEnc=$((duration / 10))
ffmpeg \
-y \
-hide_banner \
+6 -5
View File
@@ -170,15 +170,16 @@ check_for_req_pkgs() {
if missing_cmd rustup; then
echo_warn "installing rustup"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# shellcheck disable=SC2016
grep -q 'source "${HOME}/.cargo/env"' "${HOME}/.bashrc" ||
echo 'source "${HOME}/.cargo/env"' >>"${HOME}/.bashrc"
# shellcheck disable=SC1091
fi
if missing_cmd cargo; then
source "${HOME}/.bashrc"
fi
fi
has_cmd cargo-cbuild || echo_if_fail cargo install cargo-c || return 1
if ! has_cmd cargo-cbuild; then
echo_info "installing cargo-c"
echo_if_fail cargo install cargo-c || return 1
fi
echo_pass "cargo-c is installed"
echo_pass "all required packages installed"
+3 -3
View File
@@ -14,7 +14,7 @@ gen_function_info() {
gen_compile_opts_info() {
for opt in "${FB_COMP_OPTS[@]}"; do
declare -n defOptVal="DEFAULT_${opt}"
echo "- \`${opt}\`: ${FB_COMP_OPTS_DESC[${opt}]} (default: ${defOptVal})"
echo "- \`${opt}\`: ${FB_COMP_OPTS_DESC[${opt}]}. default: ${defOptVal}"
done
}
@@ -70,11 +70,11 @@ ENABLE='libdav1d' ./scripts/docker_run_image.sh ubuntu ./scripts/build.sh
# Encoding scripts
The encoding scripts are designed to be installed to system paths for re-use via symbolic links back to this repo using the \`-I\` flag.
## Encoding with svtav1-psy and opus
## Encoding with svtav1 and opus
\`\`\`bash
$(encode)
\`\`\`
- Uses svtav1-psy for the video encoder.
- Uses svtav1 for the video encoder.
- Uses libopus for the audio encoder.
- Skips re-encoding av1/opus streams.
- Only maps audio streams that match the video stream language if the video stream has a defined language.
+1 -1
View File
@@ -78,7 +78,7 @@ export REPO_DIR="$(cd "$(dirname "${thisFile}")/.." && echo "$PWD")"
source "${REPO_DIR}/main.sh" || exit 1
scr_name="$(bash_basename $0)"
cmd="${scr_name//.sh/}"
if [[ $DEBUG == 1 ]]; then set -x; fi
[[ ${DEBUG} == 1 ]] && set -x
$cmd "$@"' >"${ENTRY_SCRIPT}"
chmod +x "${ENTRY_SCRIPT}"
for funcName in "${FB_FUNC_NAMES[@]}"; do