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}