Skip to content

Instantly share code, notes, and snippets.

@CobreDev
Created January 6, 2022 02:05
Show Gist options
  • Save CobreDev/73f3e23008cca5997caba35902c42520 to your computer and use it in GitHub Desktop.
Save CobreDev/73f3e23008cca5997caba35902c42520 to your computer and use it in GitHub Desktop.
A script to convert cover artwork on *.m4a files to be compatible with Rockbox. Use at your own risk
#!/bin/bash
clear
# Finds all m4a files, and loops through them while assigning the file name to "$f"
find . -type f -name '*.m4a' -exec sh -c '
for f do
echo "$f"
echo "Extracting Artwork..."
# Extracts the album artwort to "$f".jpg (baseline)
ffmpeg -i "$f" -map 0:1 "$f".jpg -v quiet > output.txt
echo "Removing old artwork..."
# Strips the embedded album art
mp4art --remove "$f" > output.txt
echo "Resizing new artwork..."
# Resizes "$f".jpg
sips -Z 800 "$f".jpg > output.txt
echo "Embedding new artwork..."
# Embeds album art back into "$f"
mp4art --add "$f".jpg "$f" > output.txt
echo "Done!"
echo
echo
rm "$f".jpg
sleep 1
done' sh {} +
echo
echo "Done, enjoy!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment