mirror of
https://gitlab.com/dabruh/dotfiles.git
synced 2025-12-07 10:46:43 +01:00
feat: add audio mode option to videncode script
This commit is contained in:
parent
b87863f375
commit
530c9307d4
1 changed files with 10 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ OVERWRITE_DIFFERENT=false
|
|||
IS_BATCH=false
|
||||
INPUT_DIR=""
|
||||
INPUT_FILES=()
|
||||
AUDIO_MODE="transcode"
|
||||
|
||||
# Prints usage information to stdout.
|
||||
usage() {
|
||||
|
|
@ -62,6 +63,7 @@ Usage: $(basename "$0") -i input.mp4 [options]
|
|||
--max-h Maximum height in pixels (default: ${DEFAULT_MAX_H})
|
||||
--overwrite-same Overwrite output even if duration matches input
|
||||
--overwrite-different Overwrite output even if duration differs from input
|
||||
--audio-mode Audio mode: transcode (default) or copy
|
||||
-h, --help Show this help
|
||||
EOF
|
||||
}
|
||||
|
|
@ -86,6 +88,7 @@ parse_args() {
|
|||
--max-h) MAX_H="$2"; shift 2 ;;
|
||||
--overwrite-same) OVERWRITE_SAME=true; shift ;;
|
||||
--overwrite-different) OVERWRITE_DIFFERENT=true; shift ;;
|
||||
--audio-mode) AUDIO_MODE="$2"; shift 2 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
--) shift; break ;;
|
||||
*) echo "Unknown argument: $1" >&2; usage; exit 1 ;;
|
||||
|
|
@ -148,8 +151,13 @@ validate_input_single() {
|
|||
|
||||
# Assembles the full ffmpeg command array with all configured options.
|
||||
build_ffmpeg_cmd() {
|
||||
# Sets audio flags to copy streams unchanged for fidelity.
|
||||
local audio_flags=("-c:a" "copy")
|
||||
# Sets audio flags to transcode to Opus or copy streams unchanged.
|
||||
local audio_flags
|
||||
if [[ "$AUDIO_MODE" == "transcode" ]]; then
|
||||
audio_flags=("-c:a" "libopus")
|
||||
else
|
||||
audio_flags=("-c:a" "copy")
|
||||
fi
|
||||
|
||||
# Constructs the ffmpeg video scaling filter to fit within max dimensions while preserving aspect ratio.
|
||||
# Scale logic: for landscape (w>h), constrain width to MAX_W and height to MAX_H;
|
||||
|
|
|
|||
Loading…
Reference in a new issue