diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..a1fa846 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,20 @@ + +# Requirements + +- [ffmpeg](https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz) + +# `audio.sh` + +Normalise audio + +``` +Usage: ./audio.sh videofile +``` + +# `cutgui.sh` + +Download and run LosslessCut in a temp directory + +``` +Usage: ./cutgui.sh +``` diff --git a/scripts/audio.sh b/scripts/audio.sh new file mode 100755 index 0000000..8212641 --- /dev/null +++ b/scripts/audio.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +mode=loudnorm + +file="$1" +outfile="${file%.*}.audiotweaked.${file##*.}" + +if [[ -z "$file" ]]; then + echo "Usage: $0 videofile" + exit 1 +fi + +if [[ "$mode" == "mean" ]]; then + # A simple way to detect mean_volume and use it to tweak the entire file + ffmpeg -i "$file" -filter:a volumedetect -f null /dev/null + read -p "Enter mean_volume: " volume + ffmpeg -i "$file" -filter:a "volume=$volume" -af "highpass=f=200, lowpass=f=3000" "$outfile" +elif [[ "$mode" == "loudnorm" ]]; then + # Use the recommended loudnorm filter + ffmpeg -i "$file" -vcodec copy -af "loudnorm" "$outfile" +else + echo "Unknown mode" + exit 1 +fi diff --git a/scripts/cutgui.sh b/scripts/cutgui.sh new file mode 100755 index 0000000..150634e --- /dev/null +++ b/scripts/cutgui.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +temp=/tmp/lossless-cut +download=https://github.com/mifi/lossless-cut/releases/download/v3.17.4/LosslessCut-linux.tar.bz2 + +mkdir -p "$temp" + +if [[ ! -f "$temp/lossless-cut" ]]; then + echo "lossless-cut not found in $temp" + echo "Downloading lossless-cut..." + wget -nv --show-progress "$download" -O "$temp/archive.tar.bz2" + echo "Extracting lossless-cut..." + tar -xf "$temp/archive.tar.bz2" -C "$temp" --strip-components=1 + echo "Successfully obtained lossless-cut" +fi + +"$temp/lossless-cut" "$@" + + +