From 1d91dcbc8af22fa70f981e1e090f1598cc3e216b Mon Sep 17 00:00:00 2001 From: yemou Date: Sun, 14 Jun 2026 10:16:29 -0400 Subject: [PATCH] vidcompress: remove default for preset Differen't codecs handle presets differently with some not supporting presets at all. Also, while h265 with the veryslow preset is pretty fast, the same can't be said for other codecs where this could end up taking hours. --- scritps/vidcompress | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/scritps/vidcompress b/scritps/vidcompress index c1f6fb5..513ccd5 100755 --- a/scritps/vidcompress +++ b/scritps/vidcompress @@ -1,11 +1,13 @@ #!/bin/sh +# TODO: Add hardware acceleration support +# TODO: More consistently find a way to delete ffmpeg log files usage() { - printf '%b\n' "${0##*/} -i [OPTIONS]" \ - "\noptions:" \ - "\t-c CODEC - video codec to use (default: libx264)" \ - "\t-h - display this message" \ - "\t-o FILE - output file (default: out.ext)" \ - "\t-p PRESET - encoding preset to use (default: veryslow)" \ + printf '%b\n' "${0##*/} -i [OPTIONS]" \ + "\noptions:" \ + "\t-c CODEC - video codec to use (default: libx264)" \ + "\t-h - display this message" \ + "\t-o FILE - output file (default: out.ext)" \ + "\t-p PRESET - encoding preset to use" \ "\t-t FILE_SIZE - file size to target in MiB (default: 50)" } @@ -47,18 +49,18 @@ ext="${VIDCOMP_INPUT_FILE##.*}" : "${VIDCOMP_CODEC:=libx264}" : "${VIDCOMP_TARGET_SIZE:=50}" -: "${VIDCOMP_PRESET:=veryslow}" a_bitrate="$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 \ "${VIDCOMP_INPUT_FILE}")" secs="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${VIDCOMP_INPUT_FILE}")" bitrate="$(fend floor \("${VIDCOMP_TARGET_SIZE} * 8388.608 / ${secs}" - \("${a_bitrate}" / 1000\)\))" -ffmpeg -hide_banner -loglevel warning \ - -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" -preset "${VIDCOMP_PRESET}" -pass 1 \ + +ffmpeg -hide_banner -loglevel info \ + -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" \ + ${VIDCOMP_PRESET:+"-preset" "$VIDCOMP_PRESET"} -pass 1 \ -an -f null -y /dev/null && \ -ffmpeg -hide_banner -loglevel warning \ - -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" -preset "${VIDCOMP_PRESET}" -pass 2 \ +ffmpeg -hide_banner -loglevel info \ + -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" \ + ${VIDCOMP_PRESET:+"-preset" "$VIDCOMP_PRESET"} -pass 2 \ -c:a copy "${VIDCOMP_OUTPUT_FILE}" - -rm ffmpeg2pass*.log* -- 2.51.2