aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.md1
-rwxr-xr-xtranscode.sh32
-rw-r--r--transcode.sh.18
3 files changed, 11 insertions, 30 deletions
diff --git a/README.md b/README.md
index 8ce5e12..3c4053f 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,6 @@ replaces the original atomically on success.
| `ffmpeg` | always | encoding |
| `ffprobe` | always | codec/format detection |
| `nice` | always | process priority control |
-| `bc` | only with `--saving` | percentage calculation |
| `tomlq` | only when `config.toml` is present | TOML config parsing |
## Installation
diff --git a/transcode.sh b/transcode.sh
index f89732c..0501974 100755
--- a/transcode.sh
+++ b/transcode.sh
@@ -675,7 +675,8 @@ list_presets() {
fi
local -a preset_files=()
- local f name max_name_len=0
+ local f name max_name_len
+ max_name_len=0
for f in "$PRESET_DIR"/*.sh; do
if [[ -f "$f" ]]; then
preset_files+=("$f")
@@ -702,7 +703,6 @@ list_presets() {
if [[ -L "$f" ]]; then
target_path=$(resolve_path "$f")
-
if [[ "$target_path" == "$canonical_preset_dir"/*.sh ]]; then
target_name="${target_path##*/}"
target_name="${target_name%.sh}"
@@ -1003,15 +1003,6 @@ command -v nice >/dev/null 2>&1 || {
exit $EXIT_MISSING_DEPENDENCY
}
-if [[ $SAVING -eq 1 ]]; then
- # bc is only required when --saving is active; intentionally checked here
- # rather than in the main dependency block to avoid requiring it universally.
- command -v bc >/dev/null 2>&1 || {
- error "bc not found."
- exit $EXIT_MISSING_DEPENDENCY
- }
-fi
-
if [[ $SAVING_FILE_EXPLICIT -eq 1 && $SAVING -eq 0 ]]; then
warn "--saving-file has no effect without --saving"
fi
@@ -1140,16 +1131,13 @@ encode_one() {
# Convert ffprobe frame rate fractions like 30000/1001 to rounded integer FPS
# values for simpler encoder heuristics and logging.
- input_fps=$(
- awk -F/ '
- {
- if ($2)
- printf "%.0f\n", $1 / $2
- else
- printf "%.0f\n", $1
- }
- ' <<<"$input_frame_rate"
- )
+ local _fps_num _fps_den
+ IFS='/' read -r _fps_num _fps_den <<<"$input_frame_rate"
+ if [[ -n "$_fps_den" && "$_fps_den" -ne 0 ]]; then
+ input_fps=$(((_fps_num + _fps_den / 2) / _fps_den))
+ else
+ input_fps="$_fps_num"
+ fi
debug "Calculated input fps:" "$input_fps"
# Use a larger GOP for better compression efficiency while keeping seek
@@ -1269,7 +1257,7 @@ encode_one() {
if [[ $SAVING -eq 1 ]]; then
local pct
if [[ $original_filesize -gt 0 ]]; then
- pct=$(bc <<<"($original_filesize - $new_filesize) * 100 / $original_filesize")
+ pct=$(((original_filesize - new_filesize) * 100 / original_filesize))
else
pct=0
fi
diff --git a/transcode.sh.1 b/transcode.sh.1
index af03bf9..17d9e29 100644
--- a/transcode.sh.1
+++ b/transcode.sh.1
@@ -129,8 +129,7 @@ with the given niceness value. Defaults to
.BR \-s ", " \-\-saving
After each successful encode, append a line to the savings log file
recording the filename, original size in bytes, new size in bytes and the
-percentage saved. Requires
-.BR bc (1).
+percentage saved.
.TP
.BR \-\-saving\-file " \fIPATH\fR, " \-\-saving\-file= \fIPATH\fR
Path to the savings log file written by
@@ -397,10 +396,6 @@ A required dependency
.RB ( ffmpeg ,
.BR ffprobe ,
.BR nice ,
-.B bc
-when
-.B \-\-saving
-is active, or
.B tomlq
when
.B config.toml
@@ -457,7 +452,6 @@ transcode.sh \-\-config\-file ~/profiles/fast.toml input.mp4
.BR ffmpeg (1),
.BR ffprobe (1),
.BR nice (1),
-.BR bc (1),
.BR tomlq (1)
.SH AUTHOR
Dennis Fink <me+coding@dennisfink.me>