mirror of
https://github.com/levogevo/ffmpeg-av1-builder.git
synced 2026-01-15 16:56:18 +00:00
Merge branch 'dovi-psy' into other_encs
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
ffmpeg
|
ffmpeg
|
||||||
rav1e
|
rav1e
|
||||||
svt
|
svt*
|
||||||
|
dovi
|
||||||
aom
|
aom
|
||||||
vmaf
|
vmaf
|
||||||
dav1d
|
dav1d
|
||||||
|
|||||||
120
scripts/build.sh
120
scripts/build.sh
@@ -1,5 +1,50 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "./scripts/build.sh [-h] [-p] [-o] [r] [-a]"
|
||||||
|
echo -e "\th: display this help output"
|
||||||
|
echo -e "\tp: build svt-av1-psy with dovi library"
|
||||||
|
echo -e "\to: build other encoders x264/5 and vpx"
|
||||||
|
echo -e "\tr: build rockchip media libraries"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_git() {
|
||||||
|
git config pull.rebase false
|
||||||
|
git stash && git stash drop
|
||||||
|
git pull
|
||||||
|
}
|
||||||
|
|
||||||
|
OPTS='hpao:'
|
||||||
|
NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l)
|
||||||
|
MIN_OPT=0
|
||||||
|
# using all
|
||||||
|
MAX_OPT=$(( NUM_OPTS ))
|
||||||
|
test "$#" -lt $MIN_OPT && echo "not enough arguments" && usage && exit 1
|
||||||
|
test "$#" -gt $MAX_OPT && echo "too many arguments" && usage && exit 1
|
||||||
|
while getopts "$OPTS" flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
export BUILD_PSY="true"
|
||||||
|
echo "building psy"
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
export BUILD_OTHERS="true"
|
||||||
|
echo "building other encoders"
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
export BUILD_ROCKCHIP="true"
|
||||||
|
echo "building rockchip media platform"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "building default"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
BASE_DIR=$(pwd)
|
BASE_DIR=$(pwd)
|
||||||
SVT_DIR="$BASE_DIR/svt"
|
SVT_DIR="$BASE_DIR/svt"
|
||||||
RAV1E_DIR="$BASE_DIR/rav1e"
|
RAV1E_DIR="$BASE_DIR/rav1e"
|
||||||
@@ -10,12 +55,16 @@ DAV1D_DIR="$BASE_DIR/dav1d"
|
|||||||
OPUS_DIR="$BASE_DIR/opus"
|
OPUS_DIR="$BASE_DIR/opus"
|
||||||
RKMPP_DIR="$BASE_DIR/rkmpp"
|
RKMPP_DIR="$BASE_DIR/rkmpp"
|
||||||
RKRGA_DIR="$BASE_DIR/rkrga"
|
RKRGA_DIR="$BASE_DIR/rkrga"
|
||||||
|
DOVI_DIR="$BASE_DIR/dovi"
|
||||||
|
SVT_PSY_DIR="$BASE_DIR/svt-psy"
|
||||||
X264_DIR="$BASE_DIR/x264"
|
X264_DIR="$BASE_DIR/x264"
|
||||||
X265_DIR="$BASE_DIR/x265"
|
X265_DIR="$BASE_DIR/x265"
|
||||||
VPX_DIR="$BASE_DIR/vpx"
|
VPX_DIR="$BASE_DIR/vpx"
|
||||||
|
|
||||||
# clone
|
# clone
|
||||||
git clone --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git "$SVT_DIR"
|
git clone --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git "$SVT_DIR"
|
||||||
|
git clone --depth 1 https://github.com/quietvoid/dovi_tool "$DOVI_DIR"
|
||||||
|
git clone --depth 1 https://github.com/gianni-rosato/svt-av1-psy "$SVT_PSY_DIR"
|
||||||
git clone --depth 1 https://github.com/xiph/rav1e "$RAV1E_DIR"
|
git clone --depth 1 https://github.com/xiph/rav1e "$RAV1E_DIR"
|
||||||
git clone --depth 1 https://aomedia.googlesource.com/aom "$AOM_DIR"
|
git clone --depth 1 https://aomedia.googlesource.com/aom "$AOM_DIR"
|
||||||
git clone --depth 1 https://github.com/Netflix/vmaf "$VMAF_DIR"
|
git clone --depth 1 https://github.com/Netflix/vmaf "$VMAF_DIR"
|
||||||
@@ -45,10 +94,8 @@ export PATH="/usr/lib/ccache/:$PATH"
|
|||||||
|
|
||||||
# rockchip ffmpeg libs
|
# rockchip ffmpeg libs
|
||||||
FFMPEG_ROCKCHIP=""
|
FFMPEG_ROCKCHIP=""
|
||||||
IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no")
|
# IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no")
|
||||||
# disabling due to decode errors
|
if [[ "$BUILD_ROCKCHIP" == "true" ]]
|
||||||
IS_ROCKCHIP="no"
|
|
||||||
if [[ "$IS_ROCKCHIP" == "yes" ]]
|
|
||||||
then
|
then
|
||||||
FFMPEG_ROCKCHIP="--enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga"
|
FFMPEG_ROCKCHIP="--enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga"
|
||||||
FFMPEG_DIR="$BASE_DIR/ffmpeg-rkmpp"
|
FFMPEG_DIR="$BASE_DIR/ffmpeg-rkmpp"
|
||||||
@@ -60,8 +107,7 @@ then
|
|||||||
|
|
||||||
# build mpp
|
# build mpp
|
||||||
cd "$RKMPP_DIR/" || exit
|
cd "$RKMPP_DIR/" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
rm -rf mpp_build.user
|
rm -rf mpp_build.user
|
||||||
mkdir mpp_build.user
|
mkdir mpp_build.user
|
||||||
cd mpp_build.user || exit
|
cd mpp_build.user || exit
|
||||||
@@ -76,8 +122,7 @@ then
|
|||||||
|
|
||||||
# build rga
|
# build rga
|
||||||
cd "$RKRGA_DIR" || exit
|
cd "$RKRGA_DIR" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
rm -rf rga_build.user
|
rm -rf rga_build.user
|
||||||
mkdir rga_build.user
|
mkdir rga_build.user
|
||||||
cd rga_build.user || exit
|
cd rga_build.user || exit
|
||||||
@@ -88,9 +133,45 @@ then
|
|||||||
sudo ninja -vC rga_build.user install || exit
|
sudo ninja -vC rga_build.user install || exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$BUILD_PSY" == "true" ]];
|
||||||
|
then
|
||||||
|
# build dovi_tool
|
||||||
|
cd "$DOVI_DIR/" || exit
|
||||||
|
update_git
|
||||||
|
rm -rf ffmpeg_build.user && mkdir ffmpeg_build.user || exit
|
||||||
|
source "$HOME/.cargo/env" # for good measure
|
||||||
|
cargo clean
|
||||||
|
RUSTFLAGS="-C target-cpu=native" cargo build --release
|
||||||
|
sudo cp target/release/dovi_tool /usr/local/bin/ || exit
|
||||||
|
|
||||||
|
# build libdovi
|
||||||
|
cd dolby_vision || exit
|
||||||
|
RUSTFLAGS="-C target-cpu=native" cargo cinstall --release \
|
||||||
|
--prefix="$DOVI_DIR/ffmpeg_build.user" \
|
||||||
|
--libdir="$DOVI_DIR/ffmpeg_build.user"/lib \
|
||||||
|
--includedir="$DOVI_DIR/ffmpeg_build.user"/include
|
||||||
|
cd ffmpeg_build.user || exit
|
||||||
|
sudo cp ./lib/* /usr/local/lib/ -r || exit
|
||||||
|
sudo cp ./include/* /usr/local/include/ -r
|
||||||
|
|
||||||
|
# build svt-avt-psy
|
||||||
|
cd "$SVT_PSY_DIR/" || exit
|
||||||
|
update_git
|
||||||
|
rm -rf build_svt.user
|
||||||
|
mkdir build_svt.user
|
||||||
|
cd build_svt.user || exit
|
||||||
|
make clean
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DSVT_AV1_LTO=ON \
|
||||||
|
-DENABLE_AVX512=ON -DBUILD_TESTING=OFF \
|
||||||
|
-DCOVERAGE=OFF -DLIBDOVI_FOUND=1 \
|
||||||
|
-DCMAKE_C_FLAGS="-O3 $COMP_FLAGS" \
|
||||||
|
-DCMAKE_CXX_FLAGS="-O3 $COMP_FLAGS" || exit
|
||||||
|
make -j "$(nproc)" || exit
|
||||||
|
sudo make install
|
||||||
|
else
|
||||||
# build svt-av1
|
# build svt-av1
|
||||||
cd "$SVT_DIR/" || exit
|
cd "$SVT_DIR/" || exit
|
||||||
git pull
|
update_git
|
||||||
rm -rf build_svt.user
|
rm -rf build_svt.user
|
||||||
mkdir build_svt.user
|
mkdir build_svt.user
|
||||||
cd build_svt.user || exit
|
cd build_svt.user || exit
|
||||||
@@ -102,11 +183,11 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DSVT_AV1_LTO=ON \
|
|||||||
-DCMAKE_CXX_FLAGS="-O${OPT_LVL} $COMP_FLAGS" || exit
|
-DCMAKE_CXX_FLAGS="-O${OPT_LVL} $COMP_FLAGS" || exit
|
||||||
make -j "$(nproc)" || exit
|
make -j "$(nproc)" || exit
|
||||||
sudo make install || exit
|
sudo make install || exit
|
||||||
|
fi
|
||||||
|
|
||||||
# build rav1e
|
# build rav1e
|
||||||
cd "$RAV1E_DIR/" || exit
|
cd "$RAV1E_DIR/" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
rm -rf ffmpeg_build.user && mkdir ffmpeg_build.user || exit
|
rm -rf ffmpeg_build.user && mkdir ffmpeg_build.user || exit
|
||||||
source "$HOME/.cargo/env" # for good measure
|
source "$HOME/.cargo/env" # for good measure
|
||||||
cargo clean
|
cargo clean
|
||||||
@@ -120,8 +201,7 @@ sudo cp ./include/* /usr/local/include/ -r || exit
|
|||||||
|
|
||||||
# build aom
|
# build aom
|
||||||
cd "$AOM_DIR/" || exit
|
cd "$AOM_DIR/" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
rm -rf build_aom.user
|
rm -rf build_aom.user
|
||||||
mkdir build_aom.user
|
mkdir build_aom.user
|
||||||
cd build_aom.user || exit
|
cd build_aom.user || exit
|
||||||
@@ -135,8 +215,7 @@ sudo make install || exit
|
|||||||
|
|
||||||
# build libvmaf
|
# build libvmaf
|
||||||
cd "$VMAF_DIR/libvmaf" || exit
|
cd "$VMAF_DIR/libvmaf" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
python3 -m virtualenv .venv
|
python3 -m virtualenv .venv
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
rm -rf build.user
|
rm -rf build.user
|
||||||
@@ -150,8 +229,7 @@ sudo ninja -vC build.user install || exit
|
|||||||
|
|
||||||
# build dav1d
|
# build dav1d
|
||||||
cd "$DAV1D_DIR" || exit
|
cd "$DAV1D_DIR" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
rm -rf build.user
|
rm -rf build.user
|
||||||
mkdir build.user
|
mkdir build.user
|
||||||
cd build.user || exit
|
cd build.user || exit
|
||||||
@@ -162,8 +240,7 @@ sudo ninja -vC build.user install || exit
|
|||||||
|
|
||||||
# build opus
|
# build opus
|
||||||
cd "$OPUS_DIR" || exit
|
cd "$OPUS_DIR" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
./autogen.sh || exit
|
./autogen.sh || exit
|
||||||
export CFLAGS="-O${OPT_LVL} -flto $COMP_FLAGS"
|
export CFLAGS="-O${OPT_LVL} -flto $COMP_FLAGS"
|
||||||
./configure || exit
|
./configure || exit
|
||||||
@@ -224,8 +301,7 @@ sudo ldconfig
|
|||||||
|
|
||||||
# build ffmpeg
|
# build ffmpeg
|
||||||
cd "$FFMPEG_DIR/" || exit
|
cd "$FFMPEG_DIR/" || exit
|
||||||
git stash && git stash drop
|
update_git
|
||||||
git pull
|
|
||||||
export PKG_CONFIG_PATH+=":$(pkg-config --variable pc_path pkg-config)"
|
export PKG_CONFIG_PATH+=":$(pkg-config --variable pc_path pkg-config)"
|
||||||
./configure --enable-libsvtav1 --enable-librav1e \
|
./configure --enable-libsvtav1 --enable-librav1e \
|
||||||
--enable-libaom --enable-libvmaf \
|
--enable-libaom --enable-libvmaf \
|
||||||
@@ -240,6 +316,7 @@ export PKG_CONFIG_PATH+=":$(pkg-config --variable pc_path pkg-config)"
|
|||||||
--disable-podpages --disable-txtpages || exit
|
--disable-podpages --disable-txtpages || exit
|
||||||
make -j "$(nproc)" || exit
|
make -j "$(nproc)" || exit
|
||||||
sudo make install || exit
|
sudo make install || exit
|
||||||
|
sudo cp ff*_g /usr/local/bin/
|
||||||
|
|
||||||
# validate encoders
|
# validate encoders
|
||||||
hash -r
|
hash -r
|
||||||
@@ -247,3 +324,4 @@ source ~/.profile
|
|||||||
ffmpeg -encoders 2>&1 | grep "av1"
|
ffmpeg -encoders 2>&1 | grep "av1"
|
||||||
ffmpeg -encoders 2>&1 | grep "rkmpp"
|
ffmpeg -encoders 2>&1 | grep "rkmpp"
|
||||||
ffmpeg -decoders 2>&1 | grep "rkmpp"
|
ffmpeg -decoders 2>&1 | grep "rkmpp"
|
||||||
|
exit 0
|
||||||
|
|||||||
@@ -4,20 +4,35 @@
|
|||||||
# do not take this as a holy grail.
|
# do not take this as a holy grail.
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "unrecognized arguments, please retry"
|
echo "encode -i input_file [-p true/false] [-g NUM] output_file"
|
||||||
echo "encode -i input_file [-p] output_file"
|
echo -e "\t-p print the command instead of executing it [optional]"
|
||||||
echo -e "\t-p print the command instead of executing [optional]"
|
echo -e "\t-g set film grain for encode [optional]"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
encode() {
|
encode() {
|
||||||
ENCODE_FILE="/tmp/encode.sh"
|
ENCODE_FILE="/tmp/encode.sh"
|
||||||
|
SVT_PARAMS="${GRAIN}tune=0:enable-overlays=1:scd=1:enable-hdr=1:fast-decode=1:enable-variance-boost=1:enable-qm=1:qm-min=0:qm-max=15"
|
||||||
|
UNMAP=$(unmap_streams "$INPUT")
|
||||||
|
AUDIO_FORMAT='-af "aformat=channel_layouts=7.1|5.1|stereo|mono" -c:a libopus'
|
||||||
|
AUDIO_BITRATE=$(get_bitrate_audio "$INPUT")
|
||||||
|
FFMPEG_PARAMS='-y -c:s copy -c:V libsvtav1 -pix_fmt yuv420p10le -crf 25 -preset 3 -g 240'
|
||||||
|
NL=' \\\n\t'
|
||||||
|
|
||||||
echo ffmpeg -i \""$INPUT"\" -map 0 $(unmap_streams "$INPUT") \
|
echo '#!/bin/bash' > "$ENCODE_FILE"
|
||||||
-af '"aformat=channel_layouts=7.1|5.1|stereo|mono"' -c:a libopus $(get_bitrate_audio "$INPUT") \
|
echo -e ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \
|
||||||
-c:s copy -c:V libsvtav1 -pix_fmt yuv420p10le -crf 25 -preset 3 -g 240 \
|
$AUDIO_FORMAT $NL $AUDIO_BITRATE \
|
||||||
-svtav1-params \"tune=0:enable-overlays=1:scd=1:enable-hdr=1:fast-decode=1:enable-variance-boost=1\" \
|
"$FFMPEG_PARAMS" -dolbyvision 1 -svtav1-params \
|
||||||
\""$OUTPUT"\" "&& mkvpropedit \"$OUTPUT\" --add-track-statistics-tags " > "$ENCODE_FILE"
|
$NL "\"$SVT_PARAMS\" \"$OUTPUT\" ||" $NL \
|
||||||
|
ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \
|
||||||
|
$AUDIO_FORMAT $NL $AUDIO_BITRATE \
|
||||||
|
"$FFMPEG_PARAMS" -svtav1-params \
|
||||||
|
$NL "\"$SVT_PARAMS\" \"$OUTPUT\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
|
if [[ "$EXT" == "mkv" ]]; then
|
||||||
|
echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE"
|
||||||
|
echo "mkvpropedit \"$OUTPUT\" --edit info --set \"title=\"" >> "$ENCODE_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$PRINT_OUT" == "true" ]];
|
if [[ "$PRINT_OUT" == "true" ]];
|
||||||
then
|
then
|
||||||
@@ -50,22 +65,39 @@ get_bitrate_audio() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OPTS='i:p'
|
OPTS='i:p:g:'
|
||||||
NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l)
|
NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l)
|
||||||
PRINT_OUT="false"
|
PRINT_OUT="false"
|
||||||
|
GRAIN=""
|
||||||
|
# only using -i
|
||||||
MIN_OPT=2
|
MIN_OPT=2
|
||||||
MAX_OPT=4
|
# using all + output name
|
||||||
test "$#" -lt $MIN_OPT && usage && exit 1
|
MAX_OPT=$(( NUM_OPTS * 2 - 1 ))
|
||||||
test "$#" -gt $MAX_OPT && usage && exit 1
|
test "$#" -lt $MIN_OPT && echo "not enough arguments" && usage && exit 1
|
||||||
|
test "$#" -gt $MAX_OPT && echo "too many arguments" && usage && exit 1
|
||||||
while getopts "$OPTS" flag; do
|
while getopts "$OPTS" flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
i)
|
i)
|
||||||
INPUT="${OPTARG}"
|
INPUT="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
PRINT_OUT="true"
|
PRINT_OUT="${OPTARG}"
|
||||||
|
if [[ "$PRINT_OUT" != "false" && "$PRINT_OUT" != "true" ]]; then
|
||||||
|
echo "unrecognized argument for -p: $PRINT_OUT"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
g)
|
||||||
|
if [[ ${OPTARG} != ?(-)+([[:digit:]]) || ${OPTARG} -lt 0 ]]; then
|
||||||
|
echo "${OPTARG} is not a positive integer"
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
GRAIN="film-grain=${OPTARG}:film-grain-denoise=1:"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
echo "wrong flags given"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
@@ -73,21 +105,19 @@ while getopts "$OPTS" flag; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# allow optional output filename
|
# allow optional output filename
|
||||||
if [[ "$#" -eq $MAX_OPT ]]; then
|
if [[ $(($# % 2)) != 0 ]]; then
|
||||||
OUTPUT="${@: -1}"
|
OUTPUT="${@: -1}"
|
||||||
elif [[
|
|
||||||
("$PRINT_OUT" == "true") &&
|
|
||||||
( "$#" -eq 3)
|
|
||||||
]]; then
|
|
||||||
OUTPUT="${HOME}/av1_${INPUT}"
|
|
||||||
elif [[ "$#" -eq 2 ]]; then
|
|
||||||
OUTPUT="${HOME}/av1_${INPUT}"
|
|
||||||
else
|
else
|
||||||
OUTPUT="${@: -1}"
|
OUTPUT="${HOME}/av1_${INPUT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
# always use same container for output
|
||||||
echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, OUTPUT: $OUTPUT"
|
INP_FILENAME=$(basename -- "$INPUT")
|
||||||
echo
|
EXT="${INP_FILENAME##*.}"
|
||||||
|
OUTPUT="${OUTPUT%.*}"
|
||||||
|
OUTPUT+=".${EXT}"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, GRAIN: $GRAIN, OUTPUT: $OUTPUT"
|
||||||
|
echo
|
||||||
encode
|
encode
|
||||||
|
|||||||
5
scripts/refresh_build.sh
Executable file
5
scripts/refresh_build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
git pull
|
||||||
|
bash ./scripts/install_deps.sh || exit 1
|
||||||
|
bash ./scripts/build.sh || exit 1
|
||||||
Reference in New Issue
Block a user