Created
December 19, 2023 14:13
-
-
Save andrey-utkin/c456b0fed79f2d82b2ce270708c462e4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -euo pipefail | |
OPUS_FILE=$1 | |
COVER_ART_WEBP=${OPUS_FILE/.opus/.webp} | |
[[ -f "$OPUS_FILE" ]] | |
[[ -f "$COVER_ART_WEBP" ]] | |
FFMETADATA_TMPFILE=$(mktemp --suffix .cover-art.ffmetadata) | |
PNG_COVER_TMPFILE=$(mktemp --suffix .cover-art.png) | |
ffmpeg -i "$COVER_ART_WEBP" "$PNG_COVER_TMPFILE" -y | |
echo ';FFMETADATA1' > "$FFMETADATA_TMPFILE" | |
# https://github.com/jovaska1337/misc/blob/master/mkpblock.py | |
mkpblock.py 3 "" "$PNG_COVER_TMPFILE" >> "$FFMETADATA_TMPFILE" | |
mkdir -p with-cover-art | |
ffmpeg -i "$OPUS_FILE" -i "$FFMETADATA_TMPFILE" -map_metadata 1 -c:a copy with-cover-art/"$OPUS_FILE" -y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment