From d3184dad14b9105eaf67e1a59732d9bc8af7ae7b Mon Sep 17 00:00:00 2001 From: Levon Date: Thu, 25 Apr 2024 08:37:39 -0500 Subject: [PATCH 01/14] new recc encode --- scripts/recc_encode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index 40ff717..f96b35d 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -15,8 +15,8 @@ encode() { 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\" \ + -c:s copy -c:V libsvtav1 -pix_fmt yuv420p10le -crf 25 -preset 3 -g 240 -dolbyvision 1 -svtav1-params \ + \"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\" \ \""$OUTPUT"\" "&& mkvpropedit \"$OUTPUT\" --add-track-statistics-tags " > "$ENCODE_FILE" if [[ "$PRINT_OUT" == "true" ]]; From b4037d27ed6a038236752edad95700e5508b1dbb Mon Sep 17 00:00:00 2001 From: Levon Date: Thu, 25 Apr 2024 20:11:26 -0500 Subject: [PATCH 02/14] dv no --- scripts/recc_encode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index f96b35d..cc34f01 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -15,7 +15,7 @@ encode() { 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 -dolbyvision 1 -svtav1-params \ + -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:enable-qm=1:qm-min=0:qm-max=15\" \ \""$OUTPUT"\" "&& mkvpropedit \"$OUTPUT\" --add-track-statistics-tags " > "$ENCODE_FILE" From 7653256293cd203d765e7780633f9d693932697a Mon Sep 17 00:00:00 2001 From: Levon Date: Fri, 26 Apr 2024 08:07:26 -0500 Subject: [PATCH 03/14] dv ok --- scripts/recc_encode.sh | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index cc34f01..661077f 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -12,19 +12,29 @@ usage() { encode() { ENCODE_FILE="/tmp/encode.sh" + SVT_PARAMS="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"' + AUDIO_BITRATE=$(get_bitrate_audio "$INPUT") + FFMPEG_PARAMS='-y -c:s copy -c:V libsvtav1 -pix_fmt yuv420p10le -crf 25 -preset 3 -g 240' - 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:enable-qm=1:qm-min=0:qm-max=15\" \ - \""$OUTPUT"\" "&& mkvpropedit \"$OUTPUT\" --add-track-statistics-tags " > "$ENCODE_FILE" + echo ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \ + $AUDIO_FORMAT -c:a libopus $AUDIO_BITRATE \ + "$FFMPEG_PARAMS" -dolbyvision 1 -svtav1-params \ + "\"$SVT_PARAMS\" \"$OUTPUT\" ||" \ + ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \ + $AUDIO_FORMAT -c:a libopus $AUDIO_BITRATE \ + "$FFMPEG_PARAMS" -svtav1-params \ + "\"$SVT_PARAMS\" \"$OUTPUT\"" > "$ENCODE_FILE" - if [[ "$PRINT_OUT" == "true" ]]; - then - cat "$ENCODE_FILE" - else - bash "$ENCODE_FILE" - fi + echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE" + + if [[ "$PRINT_OUT" == "true" ]]; + then + cat "$ENCODE_FILE" + else + bash "$ENCODE_FILE" + fi } unmap_streams(){ From f055520ceb41b3bfaab8ad690af78899e1709398 Mon Sep 17 00:00:00 2001 From: Levon Date: Fri, 26 Apr 2024 08:27:22 -0500 Subject: [PATCH 04/14] clearer --- scripts/recc_encode.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index 661077f..e0bd417 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -14,18 +14,20 @@ encode() { ENCODE_FILE="/tmp/encode.sh" SVT_PARAMS="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"' + 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 \ - $AUDIO_FORMAT -c:a libopus $AUDIO_BITRATE \ + echo '#!/bin/bash' > "$ENCODE_FILE" + echo -e ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \ + $AUDIO_FORMAT $NL $AUDIO_BITRATE \ "$FFMPEG_PARAMS" -dolbyvision 1 -svtav1-params \ - "\"$SVT_PARAMS\" \"$OUTPUT\" ||" \ + $NL "\"$SVT_PARAMS\" \"$OUTPUT\" ||" $NL \ ffmpeg -i \""$INPUT"\" -map 0 $UNMAP \ - $AUDIO_FORMAT -c:a libopus $AUDIO_BITRATE \ + $AUDIO_FORMAT $NL $AUDIO_BITRATE \ "$FFMPEG_PARAMS" -svtav1-params \ - "\"$SVT_PARAMS\" \"$OUTPUT\"" > "$ENCODE_FILE" + $NL "\"$SVT_PARAMS\" \"$OUTPUT\"" >> "$ENCODE_FILE" echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE" From 35300a65b9de8910297d189438b85e5a3212ab50 Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Mon, 29 Apr 2024 17:38:03 -0700 Subject: [PATCH 05/14] install ff*_g --- scripts/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.sh b/scripts/build.sh index eed0f16..af9e209 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -184,6 +184,7 @@ make clean --disable-podpages --disable-txtpages || exit make -j "$(nproc)" || exit sudo make install || exit +sudo cp ff*_g /usr/local/bin/ # validate encoders hash -r From 27e1951da61d884d30772098cf371a9f2638783e Mon Sep 17 00:00:00 2001 From: Levon Gevorgyan Date: Wed, 8 May 2024 16:21:42 -0500 Subject: [PATCH 06/14] remove title --- scripts/recc_encode.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index e0bd417..e9c46b4 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -30,6 +30,7 @@ encode() { $NL "\"$SVT_PARAMS\" \"$OUTPUT\"" >> "$ENCODE_FILE" echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE" + echo "mkvpropedit \"$OUTPUT\" --edit info --set \"title=\"" >> "$ENCODE_FILE" if [[ "$PRINT_OUT" == "true" ]]; then From 3c94224653f56bd1eb7510f5144fa6ded4b88471 Mon Sep 17 00:00:00 2001 From: Levon Date: Fri, 10 May 2024 18:13:26 -0500 Subject: [PATCH 07/14] add grain arg --- scripts/recc_encode.sh | 47 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index e0bd417..dfce7d8 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -4,15 +4,15 @@ # 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]" + echo "encode -i input_file [-p true/false] [-g NUM] output_file" + echo -e "\t-p print the command instead of executing it [optional]" + echo -e "\t-g set film grain for encode [optional]" return 0 } encode() { ENCODE_FILE="/tmp/encode.sh" - SVT_PARAMS="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" + 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") @@ -62,22 +62,39 @@ get_bitrate_audio() { } -OPTS='i:p' +OPTS='i:p:g:' NUM_OPTS=$(echo $OPTS | tr ':' '\n' | wc -l) PRINT_OUT="false" +GRAIN="" +# only using -i MIN_OPT=2 -MAX_OPT=4 -test "$#" -lt $MIN_OPT && usage && exit 1 -test "$#" -gt $MAX_OPT && usage && exit 1 +# using all + output name +MAX_OPT=$(( NUM_OPTS * 2 - 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 case "${flag}" in i) INPUT="${OPTARG}" ;; 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}:" ;; *) + echo "wrong flags given" usage exit 1 ;; @@ -87,19 +104,11 @@ 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}" + OUTPUT="${HOME}/av1_${INPUT}" fi echo -echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, OUTPUT: $OUTPUT" +echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, GRAIN: $GRAIN, OUTPUT: $OUTPUT" echo - encode From 9541d12a1fdc83958bb5d1f2d47f7846b60769ae Mon Sep 17 00:00:00 2001 From: Levon Date: Sun, 12 May 2024 11:51:41 -0500 Subject: [PATCH 08/14] fix wrong output --- scripts/recc_encode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index 76bcd6d..4e3ace1 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -103,7 +103,7 @@ while getopts "$OPTS" flag; do done # allow optional output filename -if [[ "$#" -eq $MAX_OPT ]]; then +if [[ $(($# % 2)) != 0 ]]; then OUTPUT="${@: -1}" else OUTPUT="${HOME}/av1_${INPUT}" From e2da935f48ada713e919a1945f2a8992f7d8b018 Mon Sep 17 00:00:00 2001 From: Levon Date: Sun, 12 May 2024 12:08:13 -0500 Subject: [PATCH 09/14] always use same container for output --- scripts/recc_encode.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index 4e3ace1..bd966c7 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -109,6 +109,12 @@ else OUTPUT="${HOME}/av1_${INPUT}" fi +# always use same container for output +INP_FILENAME=$(basename -- "$INPUT") +EXT="${INP_FILENAME##*.}" +OUTPUT="${OUTPUT%.*}" +OUTPUT+=".${EXT}" + echo echo "INPUT: $INPUT, PRINT_OUT: $PRINT_OUT, GRAIN: $GRAIN, OUTPUT: $OUTPUT" echo From 0ef7d02b40713db72286d548a602258685668b01 Mon Sep 17 00:00:00 2001 From: Levon Date: Mon, 13 May 2024 19:59:55 -0500 Subject: [PATCH 10/14] denoise = 1 --- scripts/recc_encode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index bd966c7..b1a8643 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -12,7 +12,7 @@ usage() { encode() { 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" + 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") @@ -92,7 +92,7 @@ while getopts "$OPTS" flag; do usage exit 1 fi - GRAIN="film-grain=${OPTARG}:" + GRAIN="film-grain=${OPTARG}::film-grain-denoise=1" ;; *) echo "wrong flags given" From 74dbf68bcc0752609ac9df717d09badbb6d50b8e Mon Sep 17 00:00:00 2001 From: Levon Date: Mon, 13 May 2024 20:03:52 -0500 Subject: [PATCH 11/14] refresh build --- scripts/refresh_build.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 scripts/refresh_build.sh diff --git a/scripts/refresh_build.sh b/scripts/refresh_build.sh new file mode 100755 index 0000000..eb1895f --- /dev/null +++ b/scripts/refresh_build.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +git pull +bash ./scripts/install_deps.sh || exit 1 +bash ./scripts/build.sh || exit 1 From 7968c4c2873c92c310c23625b7ac690df03e619b Mon Sep 17 00:00:00 2001 From: Levon Date: Mon, 13 May 2024 20:08:00 -0500 Subject: [PATCH 12/14] only propedit mkv --- scripts/recc_encode.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index b1a8643..b53fa37 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -29,9 +29,11 @@ encode() { "$FFMPEG_PARAMS" -svtav1-params \ $NL "\"$SVT_PARAMS\" \"$OUTPUT\"" >> "$ENCODE_FILE" - echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE" - echo "mkvpropedit \"$OUTPUT\" --edit info --set \"title=\"" >> "$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" ]]; then cat "$ENCODE_FILE" From 6279acd057595576db8e502f965456caf902b8ea Mon Sep 17 00:00:00 2001 From: Levon Date: Mon, 13 May 2024 20:15:23 -0500 Subject: [PATCH 13/14] typo --- scripts/recc_encode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index b53fa37..ae97801 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -33,7 +33,7 @@ encode() { echo "mkvpropedit \"$OUTPUT\" --add-track-statistics-tags" >> "$ENCODE_FILE" echo "mkvpropedit \"$OUTPUT\" --edit info --set \"title=\"" >> "$ENCODE_FILE" fi - + if [[ "$PRINT_OUT" == "true" ]]; then cat "$ENCODE_FILE" @@ -94,7 +94,7 @@ while getopts "$OPTS" flag; do usage exit 1 fi - GRAIN="film-grain=${OPTARG}::film-grain-denoise=1" + GRAIN="film-grain=${OPTARG}:film-grain-denoise=1:" ;; *) echo "wrong flags given" From f89cdc175454e62683ec998901ba7b032329dcb7 Mon Sep 17 00:00:00 2001 From: Levon Date: Mon, 13 May 2024 20:16:04 -0500 Subject: [PATCH 14/14] more typos --- scripts/recc_encode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/recc_encode.sh b/scripts/recc_encode.sh index ae97801..f17c327 100755 --- a/scripts/recc_encode.sh +++ b/scripts/recc_encode.sh @@ -12,7 +12,7 @@ usage() { encode() { 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" + 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")