mirror of
https://github.com/levogevo/ffmpeg-av1-builder.git
synced 2026-01-15 16:56:18 +00:00
Merge branch 'main' into other_encs
This commit is contained in:
@@ -35,4 +35,4 @@ set style line 1 \
|
||||
pointtype 7 pointsize 1.5
|
||||
|
||||
plot "$RESULTS" using 3:6 with linepoints linestyle 1
|
||||
EOF
|
||||
EOF
|
||||
|
||||
@@ -106,7 +106,7 @@ do
|
||||
elif [[ "$encoder" == "libsvtav1" ]]
|
||||
then
|
||||
PARAMS="-preset $preset -crf $crf -svtav1-params \
|
||||
scd=1:tune=0:enable-overlays=1:enable-hdr=1:fast-decode=1 "
|
||||
scd=1:tune=0:enable-overlays=1:enable-hdr=1:fast-decode=1:enable-variance-boost=1"
|
||||
elif [[ ("$encoder" == "libx264") || ("$encoder" == "libx265") ]]
|
||||
then
|
||||
test "$preset" -eq 2 && preset=veryslow
|
||||
@@ -159,4 +159,4 @@ do
|
||||
done
|
||||
|
||||
echo -e "\n\n--- Results CSV ---\n" >> "$LOG"
|
||||
cat "$CSV" >> "$LOG"
|
||||
cat "$CSV" >> "$LOG"
|
||||
|
||||
@@ -7,7 +7,7 @@ COMMON_DEP_NAMES="autoconf automake cmake libtool pkg-config bc texinfo \
|
||||
APT_DEP_NAMES="build-essential git-core g++-12 libass-dev libfreetype6-dev \
|
||||
libsdl2-dev libva-dev libvdpau-dev gcc-12 libvorbis-dev libxcb1-dev \
|
||||
libxcb-shm0-dev libxcb-xfixes0-dev zlib1g-dev libssl-dev ninja-build \
|
||||
gobjc++ python3-pip mawk libnuma-dev"
|
||||
gobjc++ python3-pip mawk libnuma-dev mediainfo mkvtoolnix"
|
||||
|
||||
PACMAN_DEP_NAMES="base-devel ninja python-pip"
|
||||
|
||||
|
||||
93
scripts/recc_encode.sh
Executable file
93
scripts/recc_encode.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
# this is simply my recommended encoding method.
|
||||
# do not take this as a holy grail.
|
||||
|
||||
usage() {
|
||||
echo "unrecognized arguments, please retry"
|
||||
echo "encode -i input_file [-p] output_file"
|
||||
echo -e "\t-p print the command instead of executing [optional]"
|
||||
return 0
|
||||
}
|
||||
|
||||
encode() {
|
||||
ENCODE_FILE="/tmp/encode.sh"
|
||||
|
||||
echo ffmpeg -i \""$INPUT"\" -map 0 $(unmap_streams "$INPUT") \
|
||||
-af '"aformat=channel_layouts=7.1|5.1|stereo|mono"' -c:a libopus $(get_bitrate_audio "$INPUT") \
|
||||
-c:s copy -c:V libsvtav1 -pix_fmt yuv420p10le -crf 25 -preset 3 -g 240 \
|
||||
-svtav1-params \"tune=0:enable-overlays=1:scd=1:enable-hdr=1:fast-decode=1:enable-variance-boost=1\" \
|
||||
\""$OUTPUT"\" "&& mkvpropedit \"$OUTPUT\" --add-track-statistics-tags " > "$ENCODE_FILE"
|
||||
|
||||
if [[ "$PRINT_OUT" == "true" ]];
|
||||
then
|
||||
cat "$ENCODE_FILE"
|
||||
else
|
||||
bash "$ENCODE_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
unmap_streams(){
|
||||
INPUT="$1"
|
||||
UNMAP_FILTER="jpeg|png"
|
||||
UNMAP_STREAMS=$(ffprobe "$INPUT" 2>&1 | grep "Stream" | grep -Ei "$UNMAP_FILTER" | cut -d':' -f2 | tr '\n' ' ')
|
||||
UNMAP_CMD=""
|
||||
for UNMAP_STREAM in $UNMAP_STREAMS; do
|
||||
UNMAP_CMD+="-map -0:$UNMAP_STREAM "
|
||||
done
|
||||
echo "$UNMAP_CMD"
|
||||
}
|
||||
|
||||
get_bitrate_audio() {
|
||||
BITRATE_CMD=""
|
||||
NUM_AUDIO_STREAMS=$(ffprobe -v error -select_streams a -show_entries stream=index -of csv=p=0 "$INPUT" | wc -l)
|
||||
for ((i = 0; i < NUM_AUDIO_STREAMS; i++)); do
|
||||
NUM_CHANNELS=$(ffprobe -v error -select_streams "a:$i" -show_entries stream=channels -of default=noprint_wrappers=1:nokey=1 "$INPUT")
|
||||
BITRATE=$((NUM_CHANNELS * 64))
|
||||
BITRATE_CMD+="-b:a:$i ${BITRATE}k "
|
||||
done
|
||||
echo "$BITRATE_CMD"
|
||||
}
|
||||
|
||||
|
||||
OPTS='i:p'
|
||||
NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l)
|
||||
PRINT_OUT="false"
|
||||
MIN_OPT=2
|
||||
MAX_OPT=4
|
||||
test "$#" -lt $MIN_OPT && usage && exit 1
|
||||
test "$#" -gt $MAX_OPT && usage && exit 1
|
||||
while getopts "$OPTS" flag; do
|
||||
case "${flag}" in
|
||||
i)
|
||||
INPUT="${OPTARG}"
|
||||
;;
|
||||
p)
|
||||
PRINT_OUT="true"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# allow optional output filename
|
||||
if [[ "$#" -eq $MAX_OPT ]]; then
|
||||
OUTPUT="${@: -1}"
|
||||
elif [[
|
||||
("$PRINT_OUT" == "true") &&
|
||||
( "$#" -eq 3)
|
||||
]]; then
|
||||
OUTPUT="${HOME}/av1_${INPUT}"
|
||||
elif [[ "$#" -eq 2 ]]; then
|
||||
OUTPUT="${HOME}/av1_${INPUT}"
|
||||
else
|
||||
OUTPUT="${@: -1}"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, OUTPUT: $OUTPUT"
|
||||
echo
|
||||
|
||||
encode
|
||||
3
scripts/recc_encode_install.sh
Executable file
3
scripts/recc_encode_install.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo ln -sf "$(pwd)/scripts/recc_encode.sh" /usr/local/bin/encode
|
||||
3
scripts/recc_encode_uninstall.sh
Executable file
3
scripts/recc_encode_uninstall.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo rm /usr/local/bin/encode
|
||||
Reference in New Issue
Block a user