Sample Header Ad - 728x90

Add image (cover art) to Opus (ogg) audio file using ffmpeg

7 votes
2 answers
4465 views
Question ======== I have 2 files: - audio.opus (extension also possible: .opus.ogg), - cover.jpg. **How can I use ffmpeg to put cover.jpg as an embedded "cover" image into audio.opus?** Constraints ----------- - I don't want to re-encode the audio (so unfortunately, opusenc --picture seems out of scope), - I don't want to re-encode the image (jpeg), although that's not much of a problem, - I don't want to transform the image into a video (!), - I'd really prefer doing it with ffmpeg and not another tool, - I don't want to hear about mp3. Expected result --------------- Here is how it should look like when it's properly done:
$ opusinfo audio_with_cover.opus
Processing file "audio_with_cover.opus"...

New logical stream (#1, serial: 39a74bbb): type opus
Encoded with libopus 1.3.1
User comments section follows...
	ENCODER=opusenc from opus-tools 0.1.10
	METADATA_BLOCK_PICTURE=3|image/jpeg||1280x720x24|
	ENCODER_OPTIONS=--bitrate 56
Opus stream 1:
	Pre-skip: 312
    [...]
Or seen from ffprobe:
$ ffprobe audio_with_cover.opus 
[ogg @ 0x55675650ca80] 761 bytes of comment header remain
Input #0, ogg, from 'audio_with_cover.opus':
  Duration: 00:02:25.64, start: 0.000000, bitrate: 71 kb/s
  Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
    Metadata:
      ENCODER         : opusenc from opus-tools 0.1.10
      ENCODER_OPTIONS : --bitrate 56
  Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 1280x720, 90k tbr, 90k tbn (attached pic)
    Metadata:
      comment         : Cover (front)
Not possible? ------------- If you know it is not possible, please let me know, I will open a feature request at ffmpeg.
Asked by Totor (21020 rep)
Sep 20, 2022, 04:10 PM
Last activity: Apr 20, 2024, 09:10 PM