summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtranscode.sh115
1 files changed, 84 insertions, 31 deletions
diff --git a/transcode.sh b/transcode.sh
index 33803e7..61ecc5e 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -190,36 +190,64 @@ debug() {
}
print_help() {
- printf "%s - %s - %s
+ printf "${BOLD}${MAGENTA}%s${ALL_OFF} - ${BOLD}${CYAN}%s${ALL_OFF} - ${BOLD}%s${ALL_OFF}
-Usage: %s [OPTION] [--] FILE...
+${BOLD}${BLUE}Usage:${ALL_OFF} ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}[OPTION]... [--]${ALL_OFF} ${BOLD}${GREEN}FILE...${ALL_OFF}
-Options:
- -c, --continue Continue with next file even if ffmpeg fails
- -f, --encodefile PATH File containing list of files to encode
- --encodefile=PATH
- -n, --dry-run Show what would be done, don't run ffmpeg
- -N, --nice VALUE Nice value for ffmpeg (default: 19)
- --nice=VALUE
- -s, --saving Log filesize savings (filename, orig, new, %%)
- --saving-file PATH Specify where to save filesize savings (default: transcode_savings)
- --saving-file=PATH
- -S, --skip-codec LIST Add codecs to skip (comma/space/colon separated)
- --skip-codec=LIST
- -l, --only-if-smaller Only overwrite files if the transcoded file is smaller
- -p, --preset NAME Load ffmpeg arguments from a preset (default: default)
- --preset=NAME
- -h, --help, -? Show this help text and exit
- -q, --quiet Do not output anything, takes precedence over -v and --verbose
- -v, --verbose Be more verbose
- --version Print script information and version
- --color Force colored output
- --no-color Disable colored output
+Long options that take a value also accept ${BOLD}${YELLOW}--option${ALL_OFF}${BOLD}${CYAN}=${ALL_OFF}${BOLD}${GREEN}VALUE${ALL_OFF} syntax.
-Examples:
+${BOLD}${BLUE}Encoding options:${ALL_OFF}
+ ${BOLD}${YELLOW}-p, --preset${ALL_OFF} ${BOLD}${GREEN}NAME${ALL_OFF} load ffmpeg arguments from a preset (default: ${BOLD}${RED}%s${ALL_OFF})
+ ${BOLD}${YELLOW}-N, --nice${ALL_OFF} ${BOLD}${GREEN}VALUE${ALL_OFF} nice value for ffmpeg (default: ${BOLD}${RED}%d${ALL_OFF})
+ ${BOLD}${YELLOW}-n, --dry-run${ALL_OFF} show what would be done, do not run ffmpeg
+ ${BOLD}${YELLOW}-l, --only-if-smaller${ALL_OFF} only replace original if new file is smaller
+ ${BOLD}${YELLOW}-c, --continue${ALL_OFF} continue with the next file even if ffmpeg fails
+
+${BOLD}${BLUE}Input options:${ALL_OFF}
+ ${BOLD}${YELLOW}-f, --encodefile${ALL_OFF} ${BOLD}${GREEN}FILE${ALL_OFF} file containing a list of files to encode
+ ${BOLD}${YELLOW}-S, --skip-codec${ALL_OFF} ${BOLD}${GREEN}LIST${ALL_OFF} skip files with these codecs;
+ ${BOLD}${GREEN}LIST${ALL_OFF} is comma, space, or colon separated
+
+${BOLD}${BLUE}Savings log options:${ALL_OFF}
+ ${BOLD}${YELLOW}-s, --saving${ALL_OFF} log filesize savings to a TSV file
+ ${BOLD}${YELLOW}--saving-file${ALL_OFF} ${BOLD}${GREEN}FILE${ALL_OFF} path for the savings log (default: ${BOLD}${RED}%s${ALL_OFF})
+
+${BOLD}${BLUE}Output options:${ALL_OFF}
+ ${BOLD}${YELLOW}-q, --quiet${ALL_OFF} suppress all output; takes precedence over ${BOLD}${YELLOW}-v${ALL_OFF}
+ ${BOLD}${YELLOW}-v, --verbose${ALL_OFF} explain what is being done
+ ${BOLD}${YELLOW}--color${ALL_OFF} force colored output
+ ${BOLD}${YELLOW}--no-color${ALL_OFF} disable colored output
+
+${BOLD}${BLUE}General options:${ALL_OFF}
+ ${BOLD}${YELLOW}-h, --help${ALL_OFF} display this help and exit
+ ${BOLD}${YELLOW}--version${ALL_OFF} output version information and exit
+
+${BOLD}${BLUE}Configuration files:${ALL_OFF}
+ ${BOLD}${CYAN}%s/<NAME>.sh${ALL_OFF}
+ preset file; must define a bash array ${BOLD}${GREEN}ffargs${ALL_OFF} with
+ the ffmpeg encoding arguments. the following
+ variables are available to presets:
+ ${BOLD}${GREEN}input_codec${ALL_OFF} e.g. h264, hevc
+ ${BOLD}${GREEN}input_pixel_format${ALL_OFF} e.g. yuv420p
+ ${BOLD}${GREEN}output_pixel_format${ALL_OFF} derived from input
+ presets are sourced as shell code; only use
+ trusted presets from trusted directories.
+
+ ${BOLD}${CYAN}%s${ALL_OFF}
+ skip file; one codec name per line, lines
+ starting with ${BOLD}${YELLOW}#${ALL_OFF} are treated as comments.
+ codecs listed here are skipped in addition to
+ any codecs passed via ${BOLD}${YELLOW}--skip-codec${ALL_OFF}.
+
+${BOLD}${BLUE}Examples:${ALL_OFF}
%s video.mp4
%s -s -f list.txt
- %s -n -N 10 my_movie.mkv\n" "$SCRIPTNAME" "$VERSION" "$DESCRIPTION" "$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME"
+ %s -n -N 10 my_movie.mkv\n" \
+ "$SCRIPTNAME" "$VERSION" "$DESCRIPTION" \
+ "$SCRIPTNAME" \
+ "$PRESET_NAME" "$NICE_VALUE" "$SAVING_FILE" \
+ "$PRESET_DIR" "$SKIP_CODECS_FILE" \
+ "$SCRIPTNAME" "$SCRIPTNAME" "$SCRIPTNAME"
}
print_version() {
@@ -229,12 +257,36 @@ ${YELLOW}${BOLD}Description:${ALL_OFF} %s
${BLUE}${BOLD}Author:${ALL_OFF} %s
${MAGENTA}${BOLD}Date of creation:${ALL_OFF} %s
${CYAN}${BOLD}Date of revision:${ALL_OFF} %s
-${RED}${BOLD}License:${ALL_OFF} %s\n" "$SCRIPTNAME" "$VERSION" "$DESCRIPTION" "$AUTHOR" "$DATE_OF_CREATION" "$DATE_OF_REVISION" "$LICENSE"
+${RED}${BOLD}License:${ALL_OFF} %s
- if [[ -f "LICENSES/${LICENSE}.txt" ]]; then
- printf "\n"
- cat "LICENSES/${LICENSE}.txt"
- fi
+Copyright (c) 2025 Dennis Fink <dennis.fink@c3l.lu>.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" \
+ "$SCRIPTNAME" "$VERSION" "$DESCRIPTION" "$AUTHOR" "$DATE_OF_CREATION" \
+ "$DATE_OF_REVISION" "$LICENSE"
}
filesize() {
@@ -407,7 +459,8 @@ load_preset() {
if [[ $# -eq 0 ]]; then
debug "No parameters were specified"
- printf "Usage: %s [OPTION] [--] FILE...\nRun '%s --help' for full usage information.\n" "$SCRIPTNAME" "$SCRIPTNAME" >&2
+ printf "${BOLD}${BLUE}Usage:${ALL_OFF} ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}[OPTION] [--]${ALL_OFF} ${BOLD}${GREEN}FILE...${ALL_OFF}
+Run ${BOLD}${MAGENTA}%s${ALL_OFF} ${BOLD}${YELLOW}--help${ALL_OFF} for full usage information.\n" "$SCRIPTNAME" "$SCRIPTNAME" >&2
exit $EXIT_USAGE_ERROR
fi