diff options
| author | Dennis Fink | 2026-05-24 21:45:38 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-05-24 21:45:38 +0200 |
| commit | d576731f91231a3e38d3f7a9ebdd2fa2b229e7dc (patch) | |
| tree | ffc028da3a5eef4c4c008ed5258075855aeed80a | |
| parent | f47b59167986789305fc209c75205290492145a6 (diff) | |
| download | transcode.sh-d576731f91231a3e38d3f7a9ebdd2fa2b229e7dc.tar.gz transcode.sh-d576731f91231a3e38d3f7a9ebdd2fa2b229e7dc.zip | |
refactor(config)!: reorganize processing settings
Move processing-related configuration keys out of [encoding] and [skip]
into a dedicated [processing] section.
Use [processing].skip_codecs, [processing].backup_dir,
[processing].only_if_smaller, [processing].verify_output, and
[processing].continue so the config structure matches the CLI help
sections.
Update README, man page, startup warnings, and debug output to use the
new configuration layout.
BREAKING CHANGE: config.toml keys for skip codecs and processing options
moved. Replace [skip].codecs with [processing].skip_codecs, and move
[encoding].backup_dir, [encoding].only_if_smaller,
[encoding].verify_output, and [encoding].continue to [processing].
Existing config files using the old keys must be updated.
| -rw-r--r-- | README.md | 78 | ||||
| -rwxr-xr-x | transcode.sh | 189 | ||||
| -rw-r--r-- | transcode.sh.1 | 43 |
3 files changed, 148 insertions, 162 deletions
@@ -155,10 +155,8 @@ ${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/config.toml Use `--config-file FILE` to load an alternative path, or `--no-config` to skip configuration loading entirely. CLI flags generally take precedence over values -in the config file. Skip codecs are additive by default: configured codecs and -CLI codecs are merged unless `--skip-codec-override` is used. The file must be -valid TOML — an unparseable file is a hard error. Requires `tomlq` when the -file is present. +in the config file. The file must be valid TOML — an unparseable file is a hard +error. Requires `tomlq` when the file is present. **Example `config.toml`:** @@ -166,11 +164,14 @@ file is present. [encoding] preset = "av1" nice = 10 -backup_dir = "backups" video_stream = "v:0" -[skip] -codecs = ["av1", "hevc"] +[processing] +skip_codecs = ["av1", "hevc"] +backup_dir = "backups" +only_if_smaller = false +verify_output = true +continue = false [size_report] enabled = true @@ -181,44 +182,22 @@ verbose = false quiet = false ``` -| Section | Key | Type | CLI equivalent | -|---------|-----|------|----------------| -| `[encoding]` | `preset` | string | `-p` | -| `[encoding]` | `nice` | integer | `-N` | -| `[encoding]` | `hwaccel` | string or boolean | `--hwaccel` / `--no-hwaccel` | -| `[encoding]` | `video_stream` | string | `--video-stream` | -| `[encoding]` | `backup_dir` | string | `--backup-dir` | -| `[encoding]` | `verify_output` | boolean | `--verify-output` | -| `[skip]` | `codecs` | array of strings | `-S` / `--skip-codec-override` | -| `[size_report]` | `enabled` | boolean | `-s` / `--no-size-report` | -| `[size_report]` | `file` | string | `--size-report-file` | -| `[output]` | `ffmpeg_loglevel` | string | `--ffmpeg-loglevel` | -| `[output]` | `quiet` | boolean | `-q` | -| `[output]` | `verbose` | boolean | `-v` | - -> **Note:** `[skip] codecs` from the config file and `--skip-codec` from the -> CLI are **merged** by default — both sources contribute to the skip list. Use -> `--skip-codec-override` to ignore configured skip codecs and use only codecs -> provided through `--skip-codec` for that run. - -> **Note:** `[encoding] hwaccel` accepts `false` (disable), `true` (use `auto`), -> or a method string such as `"vaapi"` or `"cuda"`. CLI `--hwaccel`/`--no-hwaccel` -> always takes precedence. - -> **Note:** `[encoding] backup_dir` must point to an existing directory. CLI -> `--backup-dir` always takes precedence. - -> **Note:** `[encoding] video_stream` selects the input video stream that is -> probed for preset helper variables. It defaults to `"v:0"`. Invalid config -> values are ignored with a warning and the default is used. CLI -> `--video-stream` always takes precedence. This setting does not change ffmpeg -> stream mapping in presets. - -### Codec skip list (deprecated) - -The legacy `skip.conf` file is no longer read. If it still exists, a -deprecation warning is printed at startup. Migrate its contents to -`[skip] codecs` in `config.toml` and delete the old file. +| Section | Key | Type | CLI equivalent | Note | +|---------|-----|------|----------------|------| +| `[encoding]` | `preset` | string | `-p` | | +| `[encoding]` | `nice` | integer | `-N` | | +| `[encoding]` | `hwaccel` | string or boolean | `--hwaccel` / `--no-hwaccel` | Accepts `false` (disable), `true` (use `auto`), or a method string such as `"vaapi"` or `"cuda"`| +| `[encoding]` | `video_stream` | string | `--video-stream` | Selects the input video stream that is probed for preset helper variables. It defaults to `"v:0"`. Invalid config values are ignored with a warning and the default is used. This setting does not change ffmpeg stream mapping in presets. | +| `[processing]` | `skip_codecs` | array of strings | `-S` / `--skip-codec-override` | Codecs defined here and codecs defined using `--skip-codec` from the CLI are **merged** by default. Use `--skip-codec-override` to ignore configured skip codecs and use only codecs provided through `--skip-codec` for that run. | +| `[processing]` | `backup_dir` | string | `--backup-dir` | Must point to an existing directory. | +| `[processing]` | `only_if_smaller` | boolean | `--only-if-smaller` / `--no-only-if-smaller` | | +| `[processing]` | `verify_output` | boolean | `--verify-output` / `--no-verify-output` | | +| `[processing]` | `continue` | boolean | `--continue` / `--no-continue` | | +| `[size_report]` | `enabled` | boolean | `-s` / `--no-size-report` | | +| `[size_report]` | `file` | string | `--size-report-file` | | +| `[output]` | `ffmpeg_loglevel` | string | `--ffmpeg-loglevel` | | +| `[output]` | `quiet` | boolean | `-q` | | +| `[output]` | `verbose` | boolean | `-v` | | ## Usage @@ -244,17 +223,12 @@ transcode.sh [OPTION] [--] FILE... | `--no-hwaccel` | Disable hardware acceleration (omit `-hwaccel` from ffmpeg invocation) | | `--video-stream STREAM_SELECTOR`, `--video-stream=STREAM_SELECTOR` | Select the input video stream to probe for preset helper variables, e.g. `v:0` or `v:1` (default: `v:0`) | -### Skip options - -| Option | Description | -|--------|-------------| -| `-S LIST`, `--skip-codec LIST`, `--skip-codec=LIST` | Add codecs to the effective skip list (comma/space/colon separated) | -| `--skip-codec-override` | Use only codecs from `--skip-codec`, ignoring `[skip].codecs` from config | - ### Processing options | Option | Description | |--------|-------------| +| `-S LIST`, `--skip-codec LIST`, `--skip-codec=LIST` | Add codecs to the effective skip list (comma/space/colon separated) | +| `--skip-codec-override` | Use only codecs from `--skip-codec`, ignoring `[processing].skip_codecs` from config | | `-n`, `--dry-run` | Show what would be done; don't run ffmpeg | | `--backup-dir DIR`, `--backup-dir=DIR` | Copy originals to an existing backup directory before replacing them | | `-l`, `--only-if-smaller` | Only replace original if new file is smaller | diff --git a/transcode.sh b/transcode.sh index bc62cb3..791da9b 100755 --- a/transcode.sh +++ b/transcode.sh @@ -37,8 +37,8 @@ # preset = "av1" # nice = 10 # -# [skip] -# codecs = ["av1", "hevc"] +# [processing] +# skip_codecs = ["av1", "hevc"] # # [size_report] # enabled = false @@ -49,7 +49,7 @@ # is present. # # NOTE: skip.conf is deprecated. If it exists alongside config.toml the -# script will warn and ignore it. Migrate codecs to [skip] codecs in +# script will warn and ignore it. Migrate codecs to [processing] skip_codecs in # config.toml. # # NOTES @@ -297,11 +297,9 @@ ${BOLD}${BLUE}Encoding options:${ALL_OFF} ${BOLD}${YELLOW}--no-hwaccel${ALL_OFF} disable hardware acceleration (do not pass ${BOLD}${YELLOW}-hwaccel${ALL_OFF} to ffmpeg) ${BOLD}${YELLOW}--video-stream${ALL_OFF} ${BOLD}${GREEN}STREAM_SELECTOR${ALL_OFF} video stream to probe for preset helper variables (default: ${BOLD}${RED}%s${ALL_OFF}) -${BOLD}${BLUE}Skip options:${ALL_OFF} - ${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}${YELLOW}--skip-codec-override${ALL_OFF} use only codecs from ${BOLD}${YELLOW}--skip-codec${ALL_OFF}, ignoring ${BOLD}${CYAN}[skip].codecs${ALL_OFF} from config - ${BOLD}${BLUE}Processing options:${ALL_OFF} + ${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}${YELLOW}--skip-codec-override${ALL_OFF} use only codecs from ${BOLD}${YELLOW}--skip-codec${ALL_OFF}, ignoring ${BOLD}${CYAN}[processing].skip_codecs${ALL_OFF} from config ${BOLD}${YELLOW}-n, --dry-run${ALL_OFF} show what would be done, do not run ffmpeg ${BOLD}${YELLOW}--backup-dir${ALL_OFF} ${BOLD}${GREEN}DIR${ALL_OFF} backup original files to DIR instead of overwriting them ${BOLD}${YELLOW}-l, --only-if-smaller${ALL_OFF} only replace original if new file is smaller @@ -505,7 +503,7 @@ function load_config() { # Warn about the legacy skip.conf here (not at startup) so --quiet is # respected; by this point the CLI has been fully parsed. if [[ -f "$SKIP_CODECS_FILE" ]]; then - warn "skip.conf is deprecated." "Migrate codecs to [skip] codecs in config.toml and remove $SKIP_CODECS_FILE" + warn "skip.conf is deprecated." "Migrate codecs to [processing] skip_codecs in config.toml and remove $SKIP_CODECS_FILE" fi # We use -r and not -f to allow things like /dev/null @@ -551,45 +549,6 @@ function load_config() { fi fi - # [encoding] only_if_smaller - if [[ $_CLI_ONLY_IF_SMALLER -eq 0 ]]; then - val=$(_tomlq_get '.encoding.only_if_smaller // empty') - if [[ -n "$val" ]]; then - debug "Config: encoding.only_if_smaller =" "$val" - if [[ "$val" == "true" ]]; then - ONLY_IF_SMALLER=1 - else - ONLY_IF_SMALLER=0 - fi - fi - fi - - # [encoding] continue - if [[ $_CLI_CONTINUE -eq 0 ]]; then - val=$(_tomlq_get '.encoding.continue // empty') - if [[ -n "$val" ]]; then - debug "Config: encoding.continue =" "$val" - if [[ "$val" == "true" ]]; then - CONTINUE_ON_FAIL=1 - else - CONTINUE_ON_FAIL=0 - fi - fi - fi - - # [encoding] verify_output - if [[ $_CLI_VERIFY_OUTPUT -eq 0 ]]; then - val=$(_tomlq_get '.encoding.verify_output // empty') - if [[ -n "$val" ]]; then - debug "Config: encoding.verify_output =" "$val" - if [[ "$val" == "true" ]]; then - VERIFY_OUTPUT=1 - else - VERIFY_OUTPUT=0 - fi - fi - fi - # [encoding] hwaccel if [[ $_CLI_HWACCEL -eq 0 ]]; then val=$(_tomlq_get '.encoding.hwaccel // empty') @@ -613,33 +572,73 @@ function load_config() { if [[ -n "$val" ]]; then debug "Config: encoding.video_stream =" "$val" if ! validate_stream_selector "$val"; then - warning "Ignoring invalid config value for encoding.video_stream:" "$val" - warning "Falling back to default video stream:" "$VIDEO_STREAM" + warn "Ignoring invalid config value for encoding.video_stream:" "$val" + warn "Falling back to default video stream:" "$VIDEO_STREAM" else VIDEO_STREAM="$val" fi fi fi - if [[ $_CLI_BACKUP_DIR -eq 0 ]]; then - val=$(_tomlq_get '.encoding.backup_dir // empty') - if [[ -n "$val" ]]; then - debug "Config: encoding.backup_dir =" "$val" - BACKUP_DIR="$val" - fi - fi - - # [skip] codecs + # [processing] skip_codecs # TOML array values are joined and passed through the same parser as CLI --skip-codec. # CLI --skip-codec entries are additive, so we always load config codecs # regardless of _CLI_SKIP_CODEC. Both sources merge into SKIP_CODECS, except # if --skip-codec-override is specified - val=$(_tomlq_get '(.skip.codecs | join(", "))?') + val=$(_tomlq_get '(.processing.skip_codecs | join(", "))?') if [[ -n "$val" ]]; then - debug "Config: skip.codecs =" "$val" + debug "Config: processing.skip_codecs =" "$val" parse_skip_codec_parameter "$val" fi + # [processing] backup_dir + if [[ $_CLI_BACKUP_DIR -eq 0 ]]; then + val=$(_tomlq_get '.processing.backup_dir // empty') + if [[ -n "$val" ]]; then + debug "Config: processing.backup_dir =" "$val" + BACKUP_DIR="$val" + fi + fi + + # [processing] only_if_smaller + if [[ $_CLI_ONLY_IF_SMALLER -eq 0 ]]; then + val=$(_tomlq_get '.processing.only_if_smaller // empty') + if [[ -n "$val" ]]; then + debug "Config: processing.only_if_smaller =" "$val" + if [[ "$val" == "true" ]]; then + ONLY_IF_SMALLER=1 + else + ONLY_IF_SMALLER=0 + fi + fi + fi + + # [processing] verify_output + if [[ $_CLI_VERIFY_OUTPUT -eq 0 ]]; then + val=$(_tomlq_get '.processing.verify_output // empty') + if [[ -n "$val" ]]; then + debug "Config: processing.verify_output =" "$val" + if [[ "$val" == "true" ]]; then + VERIFY_OUTPUT=1 + else + VERIFY_OUTPUT=0 + fi + fi + fi + + # [processing] continue + if [[ $_CLI_CONTINUE -eq 0 ]]; then + val=$(_tomlq_get '.processing.continue // empty') + if [[ -n "$val" ]]; then + debug "Config: processing.continue =" "$val" + if [[ "$val" == "true" ]]; then + CONTINUE_ON_FAIL=1 + else + CONTINUE_ON_FAIL=0 + fi + fi + fi + # [size_report] enabled if [[ $_CLI_SIZE_REPORT -eq 0 ]]; then val=$(_tomlq_get '.size_report.enabled // empty') @@ -662,16 +661,12 @@ function load_config() { fi fi - # [output] verbose - if [[ $_CLI_VERBOSE -eq 0 ]]; then - val=$(_tomlq_get '.output.verbose // empty') + # [output] ffmpeg_loglevel + if [[ $_CLI_FFMPEG_LOGLEVEL -eq 0 ]]; then + val=$(_tomlq_get '.output.ffmpeg_loglevel // empty') if [[ -n "$val" ]]; then - debug "Config: output.verbose =" "$val" - if [[ "$val" == "true" ]]; then - VERBOSE=1 - else - VERBOSE=0 - fi + debug "Config: output.ffmpeg_loglevel =" "$val" + FFMPEG_LOGLEVEL="$val" fi fi @@ -688,12 +683,16 @@ function load_config() { fi fi - # [output] ffmpeg_loglevel - if [[ $_CLI_FFMPEG_LOGLEVEL -eq 0 ]]; then - val=$(_tomlq_get '.output.ffmpeg_loglevel // empty') + # [output] verbose + if [[ $_CLI_VERBOSE -eq 0 ]]; then + val=$(_tomlq_get '.output.verbose // empty') if [[ -n "$val" ]]; then - debug "Config: output.ffmpeg_loglevel =" "$val" - FFMPEG_LOGLEVEL="$val" + debug "Config: output.verbose =" "$val" + if [[ "$val" == "true" ]]; then + VERBOSE=1 + else + VERBOSE=0 + fi fi fi @@ -1794,24 +1793,30 @@ done printf -v joined ' %s' "${!SKIP_CODECS[@]}" debug "Effective configuration:" -debug " backup-dir:" "$BACKUP_DIR" -debug " config-file:" "$CONFIG_FILE" -debug " continue:" "$CONTINUE_ON_FAIL" -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" -debug " only-if-smaller:" "$ONLY_IF_SMALLER" -debug " preset:" "$PRESET_NAME" -debug " quiet:" "$QUIET" -debug " size-report-file:" "$SIZE_REPORT_FILE" -debug " size-report:" "$SIZE_REPORT" -debug " skip-codecs:" "${joined# }" -debug " verbose:" "$VERBOSE" -debug " verify-output:" "$VERIFY_OUTPUT" -debug " video-stream:" "$VIDEO_STREAM" +debug " Input:" +debug " config-file:" "$CONFIG_FILE" +debug " encode-file:" "$ENCODE_FILE" +debug " Encoding:" +debug " preset:" "$PRESET_NAME" +debug " nice:" "$NICE_VALUE" +debug " hwaccel:" "$HWACCEL" +debug " hwaccel_value:" "$HWACCEL_VALUE" +debug " video-stream:" "$VIDEO_STREAM" +debug " Processing:" +debug " skip-codecs:" "${joined# }" +debug " skip-codec-override" "$_CLI_SKIP_CODECS_OVERRIDE" +debug " dry-run:" "$DRY_RUN" +debug " backup-dir:" "$BACKUP_DIR" +debug " only-if-smaller:" "$ONLY_IF_SMALLER" +debug " verify-output:" "$VERIFY_OUTPUT" +debug " continue:" "$CONTINUE_ON_FAIL" +debug " Size report:" +debug " size-report:" "$SIZE_REPORT" +debug " size-report-file:" "$SIZE_REPORT_FILE" +debug " Display:" +debug " ffmpeg-loglevel:" "$FFMPEG_LOGLEVEL" +debug " quiet:" "$QUIET" +debug " verbose:" "$VERBOSE" command -v ffmpeg >/dev/null 2>&1 || { error "ffmpeg not found." diff --git a/transcode.sh.1 b/transcode.sh.1 index caa4c1a..5d6d521 100644 --- a/transcode.sh.1 +++ b/transcode.sh.1 @@ -118,27 +118,26 @@ or .BR v:1 . This option does not change ffmpeg stream mapping; presets remain responsible for selecting which stream to encode. -.SS "Skip options" +.SS "Processing options" .TP .BR \-S " \fILIST\fR, " \-\-skip\-codec " \fILIST\fR, " \-\-skip\-codec= \fILIST\fR Comma-, space- or colon-separated list of video codec names to skip. Files whose detected input codec appears in this list are left untouched. By default, codecs specified here are merged with any codecs listed under -.B [skip] codecs +.B [processing] skip_codecs in .B config.toml \(em both sources contribute to the skip list. .TP .BR \-\-skip\-codec\-override Ignore codecs listed under -.B [skip] codecs +.B [processing] skip_codecs in .B config.toml and use only codecs provided through .BR \-S / \-\-skip\-codec for this run. The position of this flag on the command line does not matter; it changes how the final skip list is resolved after all options are parsed. -.SS "Processing options" .TP .BR \-n ", " \-\-dry\-run Print what would be done without actually invoking @@ -440,18 +439,6 @@ enables it with that specific method. Equivalent to .BR \-\-hwaccel " / " \-\-no\-hwaccel . .TP -.B [encoding] verify_output -Boolean. Equivalent to -.BR \-\-verify\-output / \-\-no\-verify\-output . -Defaults to -.BR true . -.TP -.B [encoding] backup_dir -String. Existing directory where originals are copied after successful -encoding and before replacement. Equivalent to -.BR \-\-backup\-dir . -CLI \fB--backup-dir\fR takes precedence. -.TP .B [encoding] video_stream String. Input video stream to probe for preset helper variables. Defaults to .BR v:0 . @@ -460,7 +447,7 @@ Equivalent to Invalid configured values are ignored with a warning and the default is used. This setting does not change ffmpeg stream mapping in presets. .TP -.B [skip] codecs +.B [processing] skip_codecs Array of strings. Merged with any codecs from .BR \-S by default. Use @@ -468,6 +455,26 @@ by default. Use to ignore this configured list and use only codecs provided through .BR \-S / \-\-skip\-codec . .TP +.B [processing] backup_dir +String. Existing directory where originals are copied after successful +encoding and before replacement. Equivalent to +.BR \-\-backup\-dir . +CLI \fB--backup-dir\fR takes precedence. +.TP +.B [processing] only_if_smaller +Boolean. Equivalent to +.BR \-\-only\-if\-smaller / \-\-no\-only\-if\-smaller . +.TP +.B [processing] verify_output +Boolean. Equivalent to +.BR \-\-verify\-output / \-\-no\-verify\-output . +Defaults to +.BR true . +.TP +.B [processing] continue +Boolean. Equivalent to +.BR \-c / \-\-continue / \-\-no\-continue . +.TP .B [size_report] enabled Boolean. Equivalent to .BR \-s / \-\-no\-size\-report . @@ -495,7 +502,7 @@ Defaults to .B Deprecated. This file is no longer read. If it exists, a warning is printed. Migrate its contents to -.B [skip] codecs +.B [processing] skip_codecs in .B config.toml and delete the file. |
