summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md20
-rwxr-xr-xtranscode.sh20
-rw-r--r--transcode.sh.132
-rw-r--r--transcode.sh.bash-completion1
4 files changed, 61 insertions, 12 deletions
diff --git a/README.md b/README.md
index 32f6a0c..ab9a569 100644
--- a/README.md
+++ b/README.md
@@ -134,9 +134,11 @@ An optional TOML configuration file can be placed at:
${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/config.toml
```
-Use `--config-file FILE` to load an alternative path. CLI flags always take
-precedence over values in the config file. The file must be valid TOML — an
-unparseable file is a hard error. Requires `tomlq` when the file is present.
+Use `--config-file FILE` to load an alternative path. 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.
**Example `config.toml`:**
@@ -169,10 +171,12 @@ quiet = false
| `[output]` | `verbose` | boolean | `-v` |
| `[size_report]` | `enabled` | boolean | `-s` / `--no-size-report` |
| `[size_report]` | `file` | string | `--size-report-file` |
-| `[skip]` | `codecs` | array of strings | `-S` (merged with CLI) |
+| `[skip]` | `codecs` | array of strings | `-S` / `--skip-codec-override` |
> **Note:** `[skip] codecs` from the config file and `--skip-codec` from the
-> CLI are **merged** — both sources contribute to the skip list.
+> 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`
@@ -209,7 +213,8 @@ transcode.sh [OPTION] [--] FILE...
| `-s`, `--size-report` | Print per-file size feedback and write a status TSV log |
| `--no-size-report` | Disable a size report enabled in `config.toml` |
| `--size-report-file PATH`, `--size-report-file=PATH` | Size report TSV path (default: `transcode_size_report`) |
-| `-S LIST`, `--skip-codec LIST`, `--skip-codec=LIST` | Codecs to skip (comma/space/colon separated) |
+| `-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 |
| `-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`) |
@@ -238,6 +243,9 @@ transcode.sh --backup-dir ~/transcode-backups *.mp4
# Use a custom preset, only keep result if smaller, skip AV1 inputs
transcode.sh --preset av1_fast --only-if-smaller --skip-codec av1 /media/films/*.mkv
+# Temporarily replace the configured skip list with only HEVC
+transcode.sh --skip-codec-override --skip-codec hevc input.mkv
+
# Run at a moderate priority and continue past failures
transcode.sh --nice 10 --continue *.mp4
diff --git a/transcode.sh b/transcode.sh
index 3290596..dc6da41 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -188,6 +188,8 @@ _CLI_SIZE_REPORT=0
_CLI_SIZE_REPORT_FILE=0
_CLI_VERBOSE=0
_CLI_VERIFY_OUTPUT=0
+_CLI_SKIP_CODECS_OVERRIDE=0
+_CLI_SKIP_CODECS=()
# Values for size report
_REPORT_ENCODING_FAILED=0
@@ -299,6 +301,8 @@ ${BOLD}${BLUE}Input options:${ALL_OFF}
${BOLD}${YELLOW}-f, --encode-file${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}${YELLOW}--skip-codec-override${ALL_OFF} use only codecs from --skip-codec,
+ ignoring [skip].codecs from config
${BOLD}${BLUE}Size report options:${ALL_OFF}
${BOLD}${YELLOW}-s, --size-report${ALL_OFF} print size feedback and write a status TSV log
@@ -1553,11 +1557,15 @@ while [[ $# -gt 0 ]]; do
error "Missing value for $1"
exit $EXIT_USAGE_ERROR
fi
- parse_skip_codec_parameter "$2"
+ _CLI_SKIP_CODECS+=("$2")
shift 2
;;
--skip-codec=*)
- parse_skip_codec_parameter "${1#*=}"
+ _CLI_SKIP_CODECS+=("${1#*=}")
+ shift
+ ;;
+ --skip-codec-override)
+ _CLI_SKIP_CODECS_OVERRIDE=1
shift
;;
-l | --only-if-smaller)
@@ -1640,6 +1648,14 @@ done
# are set, but before validation so config-supplied values are validated too.
load_config
+if [[ $_CLI_SKIP_CODECS_OVERRIDE -eq 1 ]]; then
+ SKIP_CODECS=()
+fi
+
+for codec_list in "${_CLI_SKIP_CODECS[@]}"; do
+ parse_skip_codec_parameter "$codec_list"
+done
+
printf -v joined ' %s' "${!SKIP_CODECS[@]}"
debug "Effective configuration:"
diff --git a/transcode.sh.1 b/transcode.sh.1
index c827336..2dd725a 100644
--- a/transcode.sh.1
+++ b/transcode.sh.1
@@ -151,12 +151,22 @@ in the current working directory.
.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.
-Codecs specified here are merged with any codecs listed under
+By default, codecs specified here are merged with any codecs listed under
.B [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
+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.
+.TP
.BR \-l ", " \-\-only\-if\-smaller
After encoding, replace the original only when the new file is strictly
smaller. If the transcoded file is larger the temporary file is removed
@@ -358,8 +368,10 @@ sources.
.TP
.IR "${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/config.toml"
Optional TOML configuration file. Provides defaults for all options.
-CLI flags always take precedence. The file must be valid TOML; an
-unparseable file is a hard error. Requires
+CLI flags generally take precedence. Skip codecs are additive by default:
+configured codecs and CLI codecs are merged unless
+.BR \-\-skip\-codec\-override
+is used. The file must be valid TOML; an unparseable file is a hard error. Requires
.BR tomlq (1).
Supported sections and keys:
.RS
@@ -400,7 +412,11 @@ CLI \fB--backup-dir\fR takes precedence.
.TP
.B [skip] codecs
Array of strings. Merged with any codecs from
-.BR \-S .
+.BR \-S
+by default. Use
+.BR \-\-skip\-codec\-override
+to ignore this configured list and use only codecs provided through
+.BR \-S / \-\-skip\-codec .
.TP
.B [size_report] enabled
Boolean. Equivalent to
@@ -492,6 +508,14 @@ transcode.sh \-N 10 \-S av1 input.mkv
.fi
.RE
.PP
+Temporarily replace configured skip codecs with only HEVC:
+.PP
+.RS
+.nf
+transcode.sh \-\-skip\-codec\-override \-S hevc input.mkv
+.fi
+.RE
+.PP
Load an alternative configuration file:
.PP
.RS
diff --git a/transcode.sh.bash-completion b/transcode.sh.bash-completion
index 7a0529d..ea3bf74 100644
--- a/transcode.sh.bash-completion
+++ b/transcode.sh.bash-completion
@@ -167,6 +167,7 @@ _transcode_sh() {
--size-report-file=
--skip-codec
--skip-codec=
+ --skip-codec-override
--verbose
--verify-output
--version