music-to-mp3.bash: initial commit

This commit is contained in:
Aminda Suomalainen 2026-05-01 12:09:57 +03:00
parent f590d90799
commit 61236107bf
Signed by: Mikaela
GPG Key ID: 99392F62BAE30723
2 changed files with 40 additions and 0 deletions

3
bash/.gitignore vendored
View File

@ -21,3 +21,6 @@ systemd-resolv.conf-generate.bash
systemd-resolv.conf-restore.bash
traditional-resolv.conf-generate.bash
NetworkManager-resolv.conf-restore.bash
# music-to-mp3.bash
*.flac
*.mp3

37
bash/music-to-mp3.bash Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# This is just a quick script to get mp3 files for 200X or early 201X vinyl
# player that happens to have a USB port and mp3 logo and doesn't accept
# anything else.
#
# I accidentally plotted this in my head drinking tea outside.
set -x
# Without ffmpeg we are doomed to fail
if ! hash ffmpeg 2> /dev/null; then
echo "ffmpeg not found"
exit 1
fi
# Convert flacs
for flac in *.flac; do
if [ -f "$flac.mp3" ]; then
echo "$flac.mp3 already exists"
else
ffmpeg -i "$flac" "$flac.mp3"
fi
done
# Convert opus files too since yt-dlp has resulted into them
for opus in *.opus; do
if [ -f "$opus.mp3" ]; then
echo "$opus.mp3 already exists"
else
ffmpeg -i "$opus" "$opus.mp3"
fi
done
# TODO: The output have silly extensions MUSIC.{flac,opus}.mp3
set +x