8

I managed to add an album art cover to an OGG/opus file with Kid3 - Audio Tagger but I'd like to do it via the command line on all the files of an album.

I tried with ffmpeg but it did not work :

$ ffmpeg -i myMP3File.opus -i Back_Cover-SMALLER.jpg -map 0:0 -map 1:0 -c copy -metadata:s:v title="Back_Cover-SMALLER.jpg" -metadata:s:v comment="Cover (back)" out.opus
Input #0, ogg, from 'myMP3File.opus':
  Duration: 00:03:04.25, start: 0.000000, bitrate: 98 kb/s
    Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      ALBUM           : Toto
      track           : 1/14
Input #1, image2, from 'Back_Cover-SMALLER.jpg':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 27608 kb/s
    Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 768x768 [SAR 100:100 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
File 'out.opus' already exists. Overwrite ? [y/N] y
[opus @ 0x565557805300] Unsupported codec id in stream 1
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
    Last message repeated 1 times

Does anyone know another way ?

SebMa
  • 2,035

3 Answers3

0

I suggest using a Matroska wrapper around the opus. It won't re-encode the opus.

This worked for me:

mkvmerge -o "Susheela Raman - Tanpa Nama.mkv"   audio.opus  --attach-file cover.jpg

Matroska also allows you to include different size cover art (square, portrait, landscape). https://www.matroska.org/technical/cover_art/index.html

hackerb9
  • 1,117
0

Here's a method which decodes “audio.opus” and then re-encodes it to the file “merged.opus”, attaching the image “coverart.jpg” along the way:

opusdec --force-wav audio.opus - | opusenc --picture coverart.jpg - merged.opus

I don't actually use this method as I dislike transcoding audio, but it does work and keeps the file in ogg/opus format. Hopefully someday the opus-tools will be able to handle editing metadata without reencoding. (As of early 2021, they appear to be lacking.)

hackerb9
  • 1,117
0

I personally prefer using ffmpeg to alter the file data, and hopefully avoid re-encoding, such as adding chapters to video files such as mkv, and even rotating them too.

I found a solution that works, but may be client specific. When I open an OPUS audio file using mpv on Fedora Linux, after I added an image file with the same file name, what ever image file extension, such as jpg, then the program combines them in the GUI. Surely this must work with any audio file in at least the same program.

I found VLC does not provide this convenient feature automatically, but is possible if you add a parameter such as :input-slave=<image_path>.

With ffmpeg, it seems to be a bit more complex, but not terrible, and requires a video container1:

ffm \
  -loop 1 -f image2 -i "$imageFile" \
  -i "$audioFile" -c:a copy -shortest \
  <outputVideoFile>

This approach did not work for me using ffplay though :(.

Pysis
  • 1,100