This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

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.

+15 -13
+15 -13
scritps/vidcompress
··· 1 1 #!/bin/sh 2 + # TODO: Add hardware acceleration support 3 + # TODO: More consistently find a way to delete ffmpeg log files 2 4 usage() { 3 - printf '%b\n' "${0##*/} -i <input_file> [OPTIONS]" \ 4 - "\noptions:" \ 5 - "\t-c CODEC - video codec to use (default: libx264)" \ 6 - "\t-h - display this message" \ 7 - "\t-o FILE - output file (default: out.ext)" \ 8 - "\t-p PRESET - encoding preset to use (default: veryslow)" \ 5 + printf '%b\n' "${0##*/} -i <input_file> [OPTIONS]" \ 6 + "\noptions:" \ 7 + "\t-c CODEC - video codec to use (default: libx264)" \ 8 + "\t-h - display this message" \ 9 + "\t-o FILE - output file (default: out.ext)" \ 10 + "\t-p PRESET - encoding preset to use" \ 9 11 "\t-t FILE_SIZE - file size to target in MiB (default: 50)" 10 12 } 11 13 ··· 47 49 48 50 : "${VIDCOMP_CODEC:=libx264}" 49 51 : "${VIDCOMP_TARGET_SIZE:=50}" 50 - : "${VIDCOMP_PRESET:=veryslow}" 51 52 52 53 a_bitrate="$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 \ 53 54 "${VIDCOMP_INPUT_FILE}")" 54 55 secs="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${VIDCOMP_INPUT_FILE}")" 55 56 bitrate="$(fend floor \("${VIDCOMP_TARGET_SIZE} * 8388.608 / ${secs}" - \("${a_bitrate}" / 1000\)\))" 56 57 57 - ffmpeg -hide_banner -loglevel warning \ 58 - -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" -preset "${VIDCOMP_PRESET}" -pass 1 \ 58 + 59 + ffmpeg -hide_banner -loglevel info \ 60 + -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" \ 61 + ${VIDCOMP_PRESET:+"-preset" "$VIDCOMP_PRESET"} -pass 1 \ 59 62 -an -f null -y /dev/null && \ 60 - ffmpeg -hide_banner -loglevel warning \ 61 - -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" -preset "${VIDCOMP_PRESET}" -pass 2 \ 63 + ffmpeg -hide_banner -loglevel info \ 64 + -i "${VIDCOMP_INPUT_FILE}" -c:v "${VIDCOMP_CODEC}" -b:v "${bitrate}k" \ 65 + ${VIDCOMP_PRESET:+"-preset" "$VIDCOMP_PRESET"} -pass 2 \ 62 66 -c:a copy "${VIDCOMP_OUTPUT_FILE}" 63 - 64 - rm ffmpeg2pass*.log*