update:extend old scripts + new random ones

This commit is contained in:
2026-04-11 22:15:55 +09:00
parent e78e9b25f1
commit 9a23290c39
5 changed files with 81 additions and 3 deletions

View File

@@ -1,2 +1,44 @@
#!/bin/bash
ffmpeg -i "$1" -c:v libx265 -crf 24 -preset medium -c:a aac -b:a 128k "$2"
set -euo pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <original-video> <new-video>"
echo "Example: $0 input.mp4 output.webm"
exit 1
fi
INPUT="$1"
OUTPUT="$2"
if [ ! -f "$INPUT" ]; then
echo "Error: input file not found: $INPUT"
exit 1
fi
if [ "$INPUT" = "$OUTPUT" ]; then
echo "Error: input and output must be different files"
exit 1
fi
EXT=$(printf '%s' "${OUTPUT##*.}" | tr '[:upper:]' '[:lower:]')
case "$EXT" in
mp4)
ffmpeg -i "$INPUT" \
-c:v libx265 -crf 24 -preset medium \
-c:a aac -b:a 128k \
-movflags +faststart \
"$OUTPUT"
;;
webm)
ffmpeg -i "$INPUT" \
-c:v libvpx-vp9 -crf 32 -b:v 0 -deadline good -cpu-used 2 \
-c:a libopus -b:a 128k \
"$OUTPUT"
;;
*)
echo "Error: unsupported output format '.$EXT'"
echo "Use output extension: .mp4 or .webm"
exit 1
;;
esac