#!/usr/bin/env nix-shell #!nix-shell --pure -i bash -p opusTools ffmpeg mpv set -u original=$(realpath "$1") bitrates=(16 32 64 128) dir=$(mktemp -d) ffmpeg -i "$original" -map_metadata -1 -vn "$dir/original.flac" files=("$dir/original.flac") for bitrate in "${bitrates[@]}"; do opusenc --bitrate "$bitrate" "$dir/original.flac" "$dir/tmp.opus" opusdec "$dir/tmp.opus" "$dir/tmp.wav" ffmpeg -i "$dir/tmp.wav" -map_metadata -1 -vn "$dir/$bitrate.flac" rm "$dir/tmp."* files+=("$dir/$bitrate.flac") done >results playdir=$(mktemp -d) while true; do a=${files[ $(( RANDOM % ${#files[@]} )) ]} b=${files[ $(( RANDOM % ${#files[@]} )) ]} if [ "$a" = "$b" ]; then continue fi ln -sf "$a" "$playdir/a" ln -sf "$b" "$playdir/b" mpv --loop-playlist --quiet "$playdir/a" "$playdir/b" echo -n "What was better, a or b? " >&2 read result if [ "$result" = a ]; then echo "$a > $b" >> results elif [ "$result" = b ]; then echo "$a < $b" >> results else echo "$a ~ $b" >> results fi done