Last active
May 20, 2021 19:49
-
-
Save kezzico/3ecc52c48e7caac40ac0635a84794119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# convert any audio file to Animoog format | |
# usage: script.sh <source.m4a> <sample start> <sample length> | |
src="$1" | |
samplerate=44100 | |
start=$2 | |
duration=$3 | |
#targetduration=0.371519 | |
# multiply sample rate by ratio of duration / target | |
# to bring ouput length to 0.371519 | |
outrate=`python -c "print($samplerate*$duration/0.371519)"` | |
if [[ -z "$4" ]]; then | |
outfile="${src%.*}.mono.wav" | |
else | |
outfile="$4" | |
fi | |
echo "$outrate" | |
echo "$outfile" | |
echo "------------------------" | |
ffmpeg -ss $start -t $duration -i "$src" \ | |
-filter_complex "[0:a]asetrate=$outrate,aresample=44100" \ | |
-ac 1 -ab 705k "$outfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment