Fixing FLAC Album Cover


After switching my music from locally stored MP3 to a network attached storage using FLAC files, I found myself in the Samsung Q8DN media browser as well as the Yamaha MusicCast app without or only sporadic album images. Here’s how I fixed it.

I am using XLD to create FLAC files on my NAS. XLD automatically searches for cover images and saves them somehow in the files. So far, so good.

However, after transfering some albums I wanted to give it a try and listen to them using the Yamaha MusicCast app. Here I saw that some covers actually had images while some didn’t. I also checked this on a Samsung Q8DN with exactly the same result. Since I also read somewhere that some apps need a folder.jpg in the album folder, I also tried this out. I extracted the album cover from the first track and saved it as mentioned above, but without any success.

I then started to add this folder.jpg manually to all of the tracks again where no cover was visible and little to know success. I also checked the images themselves and investigated the FLAC files’ tags. At least the file format was not the reason. Some were shown, some identically saved images not, some smaller images were not shown while some larger ones were.

Luckily I found metaflac which was able to help me here and list all of the tags in a flac. This program also helped me figure out that most of my FLACs had more than just one cover image stored. So I came to the conclusion to remove all of them and re-add the folder.jpg as the one and only. This solved my problem, in the Yamaha app as well as on the TV.

Here’s a little bash script to perform this on the whole music library. My library is set up as <Album Artist Name>/<Album Name>/*.flac.

×
#!/bin/bash

# Usage: ./fix_images.sh [<album_folder>]
#   <album_folder> - optional path where FLACs and folder.jpg are stored.
#                    If not given, it will scan the whole library, where
#                    library has to use 2 subfolders, e.g.
#                      <Artist Name>/<Album Name>/*.flac
#                    This can be changed in line 33.

replace_image() {
  file="$1"
  image="$2"
  metaflac --remove --block-type=PICTURE "$file"
  metaflac --import-picture-from="$image" "$file"
}

process_dir() {
  dir="$1"
  echo "ALBUM: $dir"
  image=$dir/folder.jpg
  for file in "$dir"/*.flac; do
    if [[ -f $file ]]; then
      echo " SONG: $file"
      replace_image "$file" "$image"
    fi
  done
}

if [[ -n "$1" ]]; then
  dir="$1"
  process_dir "$dir"
else
  for dir in */*; do
    process_dir "$dir"
  done
fi

Es gibt noch keine Kommentare