mirror of
https://github.com/levogevo/ffmpeg-av1-builder.git
synced 2026-01-15 16:56:18 +00:00
crop hdr10plus and audio vers
This commit is contained in:
@@ -11,6 +11,8 @@ usage() {
|
|||||||
echo -e "\tO n: build at optimization n (1, 2, 3)"
|
echo -e "\tO n: build at optimization n (1, 2, 3)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# build with psy as default
|
||||||
|
export BUILD_PSY="true"
|
||||||
GREP_FILTER="av1"
|
GREP_FILTER="av1"
|
||||||
OPTS='hporO:'
|
OPTS='hporO:'
|
||||||
NUM_OPTS=$(echo -n $OPTS | wc -m)
|
NUM_OPTS=$(echo -n $OPTS | wc -m)
|
||||||
@@ -35,6 +37,7 @@ while getopts "$OPTS" flag; do
|
|||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
export BUILD_SVT="true"
|
export BUILD_SVT="true"
|
||||||
|
export BUILD_PSY="false"
|
||||||
echo "building svt-av1"
|
echo "building svt-av1"
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
@@ -105,6 +108,7 @@ 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"
|
DOVI_DIR="$BASE_DIR/dovi"
|
||||||
|
HDR10_DIR="$BASE_DIR/hdr10plus"
|
||||||
SVT_PSY_DIR="$BASE_DIR/svt-psy"
|
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"
|
||||||
@@ -114,9 +118,6 @@ VPX_DIR="$BASE_DIR/vpx"
|
|||||||
# save options use
|
# save options use
|
||||||
echo "$@" > "$BASE_DIR/.last_opts"
|
echo "$@" > "$BASE_DIR/.last_opts"
|
||||||
|
|
||||||
# build with psy as default
|
|
||||||
export BUILD_PSY="true"
|
|
||||||
|
|
||||||
export ARCH=$(uname -m)
|
export ARCH=$(uname -m)
|
||||||
export COMP_FLAGS=""
|
export COMP_FLAGS=""
|
||||||
if [[ "$ARCH" == "x86_64" ]]
|
if [[ "$ARCH" == "x86_64" ]]
|
||||||
@@ -147,7 +148,7 @@ git clone --depth "$GIT_DEPTH" https://github.com/FFmpeg/FFmpeg "$FFMPEG_DIR"
|
|||||||
# IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no")
|
# IS_ROCKCHIP=$(uname -r | grep "rockchip" > /dev/null && echo "yes" || echo "no")
|
||||||
if [[ "$BUILD_ROCKCHIP" == "true" ]]
|
if [[ "$BUILD_ROCKCHIP" == "true" ]]
|
||||||
then
|
then
|
||||||
FFMPEG_CONFIGURE_OPT+="--enable-gpl --enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga"
|
FFMPEG_CONFIGURE_OPT+="--enable-version3 --enable-libdrm --enable-rkmpp --enable-rkrga"
|
||||||
FFMPEG_DIR="$BASE_DIR/ffmpeg-rkmpp"
|
FFMPEG_DIR="$BASE_DIR/ffmpeg-rkmpp"
|
||||||
|
|
||||||
# clone rockchip specific repos
|
# clone rockchip specific repos
|
||||||
@@ -187,6 +188,7 @@ if [[ "$BUILD_PSY" == "true" ]];
|
|||||||
then
|
then
|
||||||
# clone svt specific repos
|
# clone svt specific repos
|
||||||
git clone --depth "$GIT_DEPTH" https://github.com/quietvoid/dovi_tool "$DOVI_DIR"
|
git clone --depth "$GIT_DEPTH" https://github.com/quietvoid/dovi_tool "$DOVI_DIR"
|
||||||
|
git clone --depth "$GIT_DEPTH" https://github.com/quietvoid/hdr10plus_tool "$HDR10_DIR"
|
||||||
git clone --depth "$GIT_DEPTH" https://github.com/gianni-rosato/svt-av1-psy "$SVT_PSY_DIR"
|
git clone --depth "$GIT_DEPTH" https://github.com/gianni-rosato/svt-av1-psy "$SVT_PSY_DIR"
|
||||||
|
|
||||||
# build dovi_tool
|
# build dovi_tool
|
||||||
@@ -208,6 +210,25 @@ then
|
|||||||
sudo cp ./lib/* /usr/local/lib/ -r || exit
|
sudo cp ./lib/* /usr/local/lib/ -r || exit
|
||||||
sudo cp ./include/* /usr/local/include/ -r
|
sudo cp ./include/* /usr/local/include/ -r
|
||||||
|
|
||||||
|
# build hdr10plus_tool
|
||||||
|
cd "$HDR10_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/hdr10plus_tool /usr/local/bin/ || exit
|
||||||
|
|
||||||
|
# build libhdr10plus
|
||||||
|
cd hdr10plus || exit
|
||||||
|
RUSTFLAGS="-C target-cpu=native" cargo cinstall --release \
|
||||||
|
--prefix="$HDR10_DIR/ffmpeg_build.user" \
|
||||||
|
--libdir="$HDR10_DIR/ffmpeg_build.user"/lib \
|
||||||
|
--includedir="$HDR10_DIR/ffmpeg_build.user"/include
|
||||||
|
cd "$HDR10_DIR"/ffmpeg_build.user || exit
|
||||||
|
sudo cp ./lib/* /usr/local/lib/ -r || exit
|
||||||
|
sudo cp ./include/* /usr/local/include/ -r
|
||||||
|
|
||||||
# build svt-avt-psy
|
# build svt-avt-psy
|
||||||
cd "$SVT_PSY_DIR/" || exit
|
cd "$SVT_PSY_DIR/" || exit
|
||||||
update_git
|
update_git
|
||||||
@@ -218,6 +239,7 @@ then
|
|||||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DSVT_AV1_LTO=ON \
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DSVT_AV1_LTO=ON \
|
||||||
-DENABLE_AVX512=ON -DBUILD_TESTING=OFF \
|
-DENABLE_AVX512=ON -DBUILD_TESTING=OFF \
|
||||||
-DCOVERAGE=OFF -DLIBDOVI_FOUND=1 \
|
-DCOVERAGE=OFF -DLIBDOVI_FOUND=1 \
|
||||||
|
-DLIBHDR10PLUS_RS_FOUND=1 \
|
||||||
-DCMAKE_C_FLAGS="-O${OPT_LVL} $COMP_FLAGS" \
|
-DCMAKE_C_FLAGS="-O${OPT_LVL} $COMP_FLAGS" \
|
||||||
-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
|
||||||
@@ -318,7 +340,7 @@ if [[ "$BUILD_OTHERS" == "true" ]]; then
|
|||||||
git clone --depth "$GIT_DEPTH" https://github.com/google/googletest "$GTEST_DIR"
|
git clone --depth "$GIT_DEPTH" https://github.com/google/googletest "$GTEST_DIR"
|
||||||
git clone --depth "$GIT_DEPTH" https://chromium.googlesource.com/webm/libvpx.git "$VPX_DIR"
|
git clone --depth "$GIT_DEPTH" https://chromium.googlesource.com/webm/libvpx.git "$VPX_DIR"
|
||||||
|
|
||||||
FFMPEG_CONFIGURE_OPT+="--enable-gpl --enable-libx264 --enable-libx265 --enable-libvpx"
|
FFMPEG_CONFIGURE_OPT+="--enable-libx264 --enable-libx265 --enable-libvpx"
|
||||||
|
|
||||||
# build x264
|
# build x264
|
||||||
cd "$X264_DIR" || exit
|
cd "$X264_DIR" || exit
|
||||||
@@ -399,7 +421,7 @@ make clean
|
|||||||
--enable-libdav1d --enable-libopus \
|
--enable-libdav1d --enable-libopus \
|
||||||
$FFMPEG_CONFIGURE_OPT \
|
$FFMPEG_CONFIGURE_OPT \
|
||||||
--arch="$ARCH" --cpu=native \
|
--arch="$ARCH" --cpu=native \
|
||||||
--enable-lto \
|
--enable-lto --enable-gpl \
|
||||||
--extra-cflags="-O${OPT_LVL} $COMP_FLAGS" \
|
--extra-cflags="-O${OPT_LVL} $COMP_FLAGS" \
|
||||||
--extra-cxxflags="-O${OPT_LVL} $COMP_FLAGS" \
|
--extra-cxxflags="-O${OPT_LVL} $COMP_FLAGS" \
|
||||||
--disable-doc --disable-htmlpages \
|
--disable-doc --disable-htmlpages \
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
# this is simply my recommended encoding method.
|
# this is simply my recommended encoding method.
|
||||||
# do not take this as a holy grail.
|
# do not take this as a holy grail.
|
||||||
|
|
||||||
|
# global path variables
|
||||||
|
SCRIPT_PATH="$(readlink "$(which "$0")")"
|
||||||
|
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
|
||||||
|
BUILDER_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "encode -i input_file [-p true/false] [-g NUM] [output_file_name] [-I] [-U]"
|
echo "encode -i input_file [-p true/false] [-g NUM] [output_file_name] [-I] [-U]"
|
||||||
echo -e "\t-p print the command instead of executing it [optional]"
|
echo -e "\t-p print the command instead of executing it [optional]"
|
||||||
@@ -33,6 +38,9 @@ encode() {
|
|||||||
VIDEO_ENCODER="libsvtav1"
|
VIDEO_ENCODER="libsvtav1"
|
||||||
echo "export VIDEO_ENCODER=\"$VIDEO_ENCODER\"" >> "$ENCODE_FILE"
|
echo "export VIDEO_ENCODER=\"$VIDEO_ENCODER\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
|
VIDEO_CROP="-vf \"$(ffmpeg -i "$INPUT" -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1)\""
|
||||||
|
echo "export VIDEO_CROP=\"$VIDEO_CROP\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
VIDEO_PARAMS="-pix_fmt yuv420p10le -crf 25 -preset 3 -g 240"
|
VIDEO_PARAMS="-pix_fmt yuv420p10le -crf 25 -preset 3 -g 240"
|
||||||
echo "export VIDEO_PARAMS=\"$VIDEO_PARAMS\"" >> "$ENCODE_FILE"
|
echo "export VIDEO_PARAMS=\"$VIDEO_PARAMS\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
@@ -46,6 +54,7 @@ encode() {
|
|||||||
echo "export VIDEO_ENC_VERSION=\"$VIDEO_ENC_VERSION\"" >> "$ENCODE_FILE"
|
echo "export VIDEO_ENC_VERSION=\"$VIDEO_ENC_VERSION\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
AUDIO_ENC_VERSION="audio_encoder=$(ldd $(which ffmpeg) | grep -i libopus | cut -d' ' -f3 | xargs readlink)"
|
AUDIO_ENC_VERSION="audio_encoder=$(ldd $(which ffmpeg) | grep -i libopus | cut -d' ' -f3 | xargs readlink)"
|
||||||
|
AUDIO_ENC_VERSION+="-g$(cd "$BUILDER_DIR/opus" && git rev-parse --short HEAD)"
|
||||||
echo "export AUDIO_ENC_VERSION=\"$AUDIO_ENC_VERSION\"" >> "$ENCODE_FILE"
|
echo "export AUDIO_ENC_VERSION=\"$AUDIO_ENC_VERSION\"" >> "$ENCODE_FILE"
|
||||||
|
|
||||||
ADD_METADATA="\"encoding_params=\$VIDEO_PARAMS \$SVT_PARAMS\""
|
ADD_METADATA="\"encoding_params=\$VIDEO_PARAMS \$SVT_PARAMS\""
|
||||||
@@ -55,6 +64,7 @@ encode() {
|
|||||||
echo >> "$ENCODE_FILE"
|
echo >> "$ENCODE_FILE"
|
||||||
|
|
||||||
echo -e ffmpeg -i \""$INPUT"\" -map 0 \$UNMAP \
|
echo -e ffmpeg -i \""$INPUT"\" -map 0 \$UNMAP \
|
||||||
|
\$VIDEO_CROP \
|
||||||
\$AUDIO_FORMAT \$AUDIO_BITRATE $NL \
|
\$AUDIO_FORMAT \$AUDIO_BITRATE $NL \
|
||||||
-metadata \"\$FFMPEG_VERSION\" \
|
-metadata \"\$FFMPEG_VERSION\" \
|
||||||
-metadata \"\$VIDEO_ENC_VERSION\" $NL \
|
-metadata \"\$VIDEO_ENC_VERSION\" $NL \
|
||||||
@@ -63,6 +73,7 @@ encode() {
|
|||||||
\$FFMPEG_PARAMS -dolbyvision 1 -svtav1-params \
|
\$FFMPEG_PARAMS -dolbyvision 1 -svtav1-params \
|
||||||
$NL \"\$SVT_PARAMS\" \"\$OUTPUT\" "||" $NL \
|
$NL \"\$SVT_PARAMS\" \"\$OUTPUT\" "||" $NL \
|
||||||
ffmpeg -i \""$INPUT"\" -map 0 \$UNMAP \
|
ffmpeg -i \""$INPUT"\" -map 0 \$UNMAP \
|
||||||
|
\$VIDEO_CROP \
|
||||||
\$AUDIO_FORMAT \$AUDIO_BITRATE $NL \
|
\$AUDIO_FORMAT \$AUDIO_BITRATE $NL \
|
||||||
-metadata \"\$FFMPEG_VERSION\" \
|
-metadata \"\$FFMPEG_VERSION\" \
|
||||||
-metadata \"\$VIDEO_ENC_VERSION\" $NL \
|
-metadata \"\$VIDEO_ENC_VERSION\" $NL \
|
||||||
|
|||||||
Reference in New Issue
Block a user