From 8bd694647022c71ee679b306fdbb5ddfc7b456ba Mon Sep 17 00:00:00 2001 From: home Date: Sun, 3 Dec 2023 04:02:44 +0300 Subject: [PATCH] ffmpeg : music_cover add support for mka cover art. --- .config/bash/module/ffmpeg.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.config/bash/module/ffmpeg.sh b/.config/bash/module/ffmpeg.sh index 72ea3d7..bd7b7e2 100644 --- a/.config/bash/module/ffmpeg.sh +++ b/.config/bash/module/ffmpeg.sh @@ -24,9 +24,18 @@ ffmpeg_mux_cover() mkdir out - for file in *.${format}; do - ffmpeg -i "${file}" -i "${cover}" -map 0 -map 0:-v? -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"${file}" || return 1 - done + case "${format}" in + "mka"|"mkv") + for file in *.${format}; do + ffmpeg -i "${file}" -attach "${cover}" -map 0 -c copy -metadata:s:t mimetype="image/${cover##*.}" -metadata:s:t:0 filename="cover.${cover##*.}" "./out/${file}" || return 1 + done + ;; + *) + for file in *.${format}; do + ffmpeg -i "${file}" -i "${cover}" -map 0 -map 0:-v? -map 1 -codec copy -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -disposition:v attached_pic ./out/"${file}" || return 1 + done + ;; + esac mv out/* . rm -d out/ && rm "${2}" @@ -57,6 +66,7 @@ ffmpeg_music_meta() local title="${file#*_}"; title="${title%.*}"; title="${title//_/ }" # echo "${artist}; ${album}; ${year}; ${track}; ${title}" + # TODO: make it format-specific. ffmpeg -i "${file}" -map 0 -c copy -metadata "artist=${artist}" -metadata "album_artist=${artist}" -metadata "album=${album}" -metadata "date=${year}" -metadata "year=${year}" -metadata "date_released=${year}" -metadata "track=${track}" -metadata "part_number=${track}" -metadata "title=${title}" ./out/"${file}" || return 1 done