2

I have a script that extracts a specified subset of my music collection. Most of my music is FLAC; since space (and supported formats) may be an issue on the target device (smartphon, car radio, ...) it can also convert "down" to OGG for MP3.

I figured out a while ago how to convert FLAC to OGG so that meta data is kept:

ffmpeg -v quiet -y -i "${infile}" \
       -codec:a libvorbis -qscale:a 6 -map_metadata 0 \
       "${outfile}"

However, I noticed that the resulting file won't play in my Android app if the FLAC contained a cover image. I did some digging; the short of it is, ffmpeg seems to create corrupt OGGs in this case.

Is this a bug, or do I have to pick different parameters?

6
  • Does the Android app you're using actually support Ogg Vorbis? Are other devices able to read or play the file? It might be possible that you need to convert to another format, such as MPEG-2 Layer 3 (.mp3) for the device or application you're using.
    – DopeGhoti
    Commented Feb 1, 2017 at 22:24
  • @DopeGhoti I guess you didn't click through to Github; OGGs without images and OGGs that had images added by other means play just fine.
    – Raphael
    Commented Feb 1, 2017 at 22:28
  • Did you try with oggenc (see linux.die.net/man/1/oggenc)? Could be a solution if ffmpeg does not work.
    – ridgy
    Commented Feb 2, 2017 at 11:25
  • @ridgy Did not; will do and update, thanks for the pointer!
    – Raphael
    Commented Feb 2, 2017 at 15:42
  • @ridgy oggenc does not keep the image. There are certainly ways to add them "by hand", but why should one have to?
    – Raphael
    Commented Feb 2, 2017 at 20:06

1 Answer 1

1

I know this is an old post, but I found it when I was experiencing the same issue. Lots of attempts later, I still couldn't find a way to get ffmpeg to save embedded cover art from a FLAC file when converting to an OGG.

I ended up finding a solution with GStreamer and decided to post in the hope that it would save someone else some time:

gst-launch-1.0 -v -m filesrc location='inputfilename.flac' ! decodebin ! audioconvert ! vorbisenc quality=0.6 ! oggmux ! filesink location='outputfilename.ogg'

The GStreamer solution worked perfectly, the cover art was embedded in the OGG file, replay gain tags from the FLAC were retained, and the cover showed up in the thumbnails for my file manager as well as in music players on Linux and Android.

You can easily include the GStreamer command in a Bash, PHP, or other script to iterate through a bunch of files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .