diff options
| author | Dennis Fink | 2026-05-19 18:31:43 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-05-19 18:31:43 +0200 |
| commit | 99e6b7ceb93db5ce9c4b70619c6ead5a2aaa281c (patch) | |
| tree | 9db42c39d8e9d360c6ecff5f2ec9c914fef17635 | |
| parent | 38cf6f1dd06176778bda3608d4ba58f6133b521e (diff) | |
| download | transcode.sh-99e6b7ceb93db5ce9c4b70619c6ead5a2aaa281c.tar.gz transcode.sh-99e6b7ceb93db5ce9c4b70619c6ead5a2aaa281c.zip | |
feat(output): make ffmpeg loglevel configurable
Add --ffmpeg-loglevel so users can choose which ffmpeg messages are
shown during encoding instead of always using the built-in default.
Load the same setting from [output].ffmpeg_loglevel when it is
configured and no CLI value was provided.
Document the new option in the README and man page, and add shell
completion for supported ffmpeg log levels.
Diffstat (limited to '')
| -rw-r--r-- | README.md | 2 | ||||
| -rwxr-xr-x | transcode.sh | 38 | ||||
| -rw-r--r-- | transcode.sh.1 | 15 | ||||
| -rw-r--r-- | transcode.sh.bash-completion | 12 |
4 files changed, 66 insertions, 1 deletions
@@ -178,6 +178,7 @@ quiet = false | `[encoding]` | `verify_output` | boolean | `--verify-output` | | `[output]` | `quiet` | boolean | `-q` | | `[output]` | `verbose` | boolean | `-v` | +| `[output]` | `ffmpeg_loglevel` | string | `--ffmpeg-loglevel` | | `[size_report]` | `enabled` | boolean | `-s` / `--no-size-report` | | `[size_report]` | `file` | string | `--size-report-file` | | `[skip]` | `codecs` | array of strings | `-S` / `--skip-codec-override` | @@ -227,6 +228,7 @@ transcode.sh [OPTION] [--] FILE... | `-l`, `--only-if-smaller` | Only replace original if new file is smaller | | `--no-only-if-smaller` | Do replace original even if new file is bigger | | `-p NAME`, `--preset NAME`, `--preset=NAME` | Preset to use (default: `default`) | +| `--ffmpeg-loglevel LEVEL`, `--ffmpeg-loglevel=LEVEL` | Specify the loglevel to pass to ffmpeg (default: `fatal`) | | `-q`, `--quiet` | Suppress all output (overrides `-v`) | | `-v`, `--verbose` | More detailed output | | `--color` / `--no-color` | Force or disable colored output | diff --git a/transcode.sh b/transcode.sh index 3e46b0e..093db93 100755 --- a/transcode.sh +++ b/transcode.sh @@ -155,6 +155,7 @@ BACKUP_DIR="" CONTINUE_ON_FAIL=0 DRY_RUN=0 ENCODE_FILE="" +FFMPEG_LOGLEVEL="fatal" HWACCEL=1 HWACCEL_VALUE="auto" NICE_VALUE=19 @@ -179,6 +180,7 @@ readonly SKIP_CODECS_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/skip.c _CLI_BACKUP_DIR=0 _CLI_CONFIG_FILE=0 _CLI_CONTINUE=0 +_CLI_FFMPEG_LOGLEVEL=0 _CLI_HWACCEL=0 _CLI_NICE=0 _CLI_ONLY_IF_SMALLER=0 @@ -310,6 +312,7 @@ ${BOLD}${BLUE}Size report options:${ALL_OFF} ${BOLD}${YELLOW}--size-report-file${ALL_OFF} ${BOLD}${GREEN}FILE${ALL_OFF} path for the size report log (default: ${BOLD}${RED}%s${ALL_OFF}) ${BOLD}${BLUE}Output options:${ALL_OFF} + ${BOLD}${YELLOW}--ffmpeg-loglevel${ALL_OFF} specify the loglevel to pass to ffmpeg (default: ${BOLD}${RED}fatal${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 @@ -656,6 +659,16 @@ load_config() { fi fi fi + + # [output] ffmpeg_loglevel + if [[ $_CLI_FFMPEG_LOGLEVEL -eq 0 ]]; then + val=$(_tomlq_get '.output.ffmpeg_loglevel // empty') + if [[ -n "$val" ]]; then + debug "Config: output.ffmpeg_loglevel =" "$val" + FFMPEG_LOGLEVEL="$val" + fi + fi + } ############################################################################### @@ -1237,7 +1250,7 @@ encode_one() { -nostdin -y -hide_banner - -v error + -v "$FFMPEG_LOGLEVEL" -stats "${hwaccel_args[@]}" -i "file:$input_file" @@ -1628,6 +1641,28 @@ while [[ $# -gt 0 ]]; do _CLI_PRESET=1 shift ;; + --ffmpeg-loglevel) + if [[ $# -lt 2 ]]; then + error "Missing value for:" "$1" + exit $EXIT_USAGE_ERROR + fi + if [[ ! -n "$2" ]]; then + error "Value for $1 must not be empty" + exit $EXIT_USAGE_ERROR + fi + FFMPEG_LOGLEVEL="$2" + _CLI_FFMPEG_LOGLEVEL=1 + shift 2 + ;; + --ffmpeg-loglevel=*) + if [[ ! -n "${1#*=}" ]]; then + error "Value for --ffmpeg-loglevel must not be empty" + exit $EXIT_USAGE_ERROR + fi + FFMPEG_LOGLEVEL="${1#*=}" + _CLI_FFMPEG_LOGLEVEL=1 + shift + ;; --) shift REMAINING_ARGS+=("$@") @@ -1663,6 +1698,7 @@ debug " backup-dir:" "$BACKUP_DIR" debug " config-file:" "$CONFIG_FILE" debug " dry-run:" "$DRY_RUN" debug " encode-file:" "$ENCODE_FILE" +debug " ffmpeg-loglevel:" "$FFMPEG_LOGLEVEL" debug " hwaccel:" "$HWACCEL" debug " hwaccel_value:" "$HWACCEL_VALUE" debug " nice:" "$NICE_VALUE" diff --git a/transcode.sh.1 b/transcode.sh.1 index 3867d1c..bc3639c 100644 --- a/transcode.sh.1 +++ b/transcode.sh.1 @@ -179,6 +179,14 @@ After encoding, replace the original also if the new file is bigger. Load the preset named \fINAME\fR from the preset directory. Defaults to .BR default . .TP +.BR \-\-ffmpeg\-loglevel " \fILEVEL\fR, " \-\-ffmpeg\-loglevel= \fILEVEL\fR +Pass +\.BI \-v " LEVEL" +to +.BR ffmpeg(1). +Defaults to +.BR fatal . +.TP .BR \-h ", " \-\-help ", " \-? Print a short help message and exit. .TP @@ -425,6 +433,7 @@ Boolean. Equivalent to .B [size_report] file String. Equivalent to .BR \-\-size\-report\-file . +.TP .B [output] verbose Boolean. Equivalent to .BR \-v . @@ -432,6 +441,12 @@ Boolean. Equivalent to .B [output] quiet Boolean. Equivalent to .BR \-q . +.TP +.B [output] ffmpeg_loglevel +String. Equivalent to +.BR \-\-ffmpeg\-loglevel . +Defaults to +.BR fatal . .RE .TP .IR "${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/skip.conf" diff --git a/transcode.sh.bash-completion b/transcode.sh.bash-completion index ea3bf74..160eb6f 100644 --- a/transcode.sh.bash-completion +++ b/transcode.sh.bash-completion @@ -38,6 +38,7 @@ _transcode_sh() { local codecs='h264 hevc av1 vp8 vp9 mpeg2video mpeg4 mjpeg theora' local nice_vals='0 5 10 15 19' local hwaccel_methods='auto cuda vaapi dxva2 d3d11va videotoolbox qsv' + local ffmpeg_loglevels='quiet panic fatal error warning info verbose debug trace' # --------------------------------------------------------------------------- # Handle --option=VALUE: cur contains the entire "--opt=val" token. @@ -85,6 +86,11 @@ _transcode_sh() { COMPREPLY=($(compgen -W "$hwaccel_methods" -- "$cur")) return ;; + --ffmpeg-loglevel=*) + cur="${cur#*=}" + COMPREPLY=($(compgen -W "$ffmpeg_loglevels" -- "$cur")) + return + ;; esac # --------------------------------------------------------------------------- @@ -125,6 +131,10 @@ _transcode_sh() { COMPREPLY=($(compgen -W "$hwaccel_methods" -- "$cur")) return ;; + --ffmpeg-loglevel) + COMPREPLY=($(compgen -W "$ffmpeg_loglevels" -- "$cur")) + return + ;; esac # --------------------------------------------------------------------------- @@ -146,6 +156,8 @@ _transcode_sh() { --dry-run --encode-file --encode-file= + --ffmpeg-loglevel + --ffmpeg-loglevel= --help --hwaccel --hwaccel= |
