0

I got a gigantonormic script to convert my FLACs to OPUS files but I'm struggling with one specific issue. When converting and trying to copy the cover image, it throws an error. Preamble, this is the part of the script handling the conversion:

find $DIRECTORY -type f \
    \( -iname "*${EXTENSIONS[0]}" $(if [ ${#EXTENSIONS[@]} -gt 1 ]; \
    then printf -- '-o -iname *%s ' "${EXTENSIONS[@]:1}"; fi) \) \
    -print0 | \
    xargs -0 -P $THREADS -I {} \
        ffmpeg -i "{}" \
        $(if [ ! $VERBOSE ]; then echo "-loglevel warning"; fi) \
        -map 0:a \
        -c:a libopus -map_metadata 0 -map_metadata:s:a 0:s:a \
        -b:a $BITRATE \
        -map 0:v \
        -c:v copy -map_metadata 0 -map_metadata:s:v 0:s:v -disposition:v:1 attached_pic \
        -y "{}.opus"

I get the following error:

Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> opus (libopus))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[opus @ 0x562a9db664c0] Unsupported codec id in stream 1
[out#0/opus @ 0x562a9db64580] Could not write header (incorrect codec parameters ?): Invalid argument
[aost#0:0/libopus @ 0x562a9db68540] Error initializing output stream: 

However, this here works:

ffmpeg -i "{}" \
  $(if [ ! $VERBOSE ]; then echo "-loglevel warning"; fi) \
  -map 0:a \
  -c:a libopus -map_metadata 0 -map_metadata:s:a 0:s:a \
  -b:a $BITRATE \
  -y "{}.opus"

As well as this here:

ffmpeg -i "{}" \
  $(if [ ! $VERBOSE ]; then echo "-loglevel warning"; fi) \
  -map 0:a \
  -map_metadata 0 -map_metadata:s:a 0:s:a \
  -b:a $BITRATE \
  -map 0:v \
  -c:v copy -map_metadata 0 -map_metadata:s:v 0:s:v -disposition:v:1 attached_pic \
  -y "{}.mp3"

The only difference is, that the latter either doesn't copy the video or outputs MP3 instead of opus. So the ffmpeg command itself should be correct as it doesn't copy the image if I don't include the video stream (in both OPUS and MP3)

This is extremely odd behaviour and I am completely out of ideas on how to fix it at this point, is this documented somewhere? It feels like an libopus issue but also why would libopus even look at the video, and if it doesn't why would it throw an error?

P.S.: Realized an ffprobe may be useful, for an OPUS file with thumbnail (created with Kid3) and for the same song the flac file

P.P.S.: before anyone gets smart on me, yes I could have done this with a for loop, I wanted a challenge more than a useful script, it just happened to be both. And yes I could do it manually, I am buying at least an Album a month and I do not want to do those manually nor do I want flacs on my Jellyfin

1

1 Answer 1

0

Currently, FFMPEG does not have native support for cover art in OGG containers, see Support writing album cover art image embedded in ogg / opus metadata - Comment 11

You can manually add an image as cover art using the -metadata:s:a METADATA_BLOCK_PICTURE=... parameter.

For a manual solution, see Add art cover in OGG audio file over on SuperUser

You must log in to answer this question.

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