From cb88aebeeffdfec28e9977fccfeaf317ff234b5a Mon Sep 17 00:00:00 2001 From: Raine Date: Sun, 14 Jan 2024 20:56:41 +0100 Subject: [PATCH] feat: shrink video experiment --- experiments/shrink-video/.gitignore | 2 ++ experiments/shrink-video/shrink.sh | 41 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 experiments/shrink-video/.gitignore create mode 100755 experiments/shrink-video/shrink.sh diff --git a/experiments/shrink-video/.gitignore b/experiments/shrink-video/.gitignore new file mode 100644 index 0000000..db044df --- /dev/null +++ b/experiments/shrink-video/.gitignore @@ -0,0 +1,2 @@ +*.webm + diff --git a/experiments/shrink-video/shrink.sh b/experiments/shrink-video/shrink.sh new file mode 100755 index 0000000..566d6fe --- /dev/null +++ b/experiments/shrink-video/shrink.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +crf=${CRF:-25} +video_codec=${VIDEO_CODEC:-libsvtav1} +audio_codec=${AUDIO_CODEC:-libopus} + +while getopts ":c:v:a:" opt; do + case $opt in + c) + crf=$OPTARG + ;; + v) + video_codec=$OPTARG + ;; + a) + audio_codec=$OPTARG + ;; + \?) + echo "no such arg!" + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [ $# -eq 0 ]; then + echo "no file selected" + exit 1 +fi + +if ! [ -f $1 ]; then + echo "no such file" + exit 2 +fi + +ffmpeg \ + -i $1 \ + -crf $crf \ + -c:v $video_codec \ + -c:a $audio_codec \ + ${2:-out.$1}