Have ffmpeg convert to .opus.ogg a way that "works"

I have a bunch of audio files with cover art, and I want to convert them to OPUS files that also have a .ogg extension to aid integration with other apps (not to mention converting to just .opus doesn’t seem to preserve the cover art at all). Currently, ffmpeg -i "$filename" -c:a libopus "$outputbasename.opus.ogg" converts the streams into something like this:

  Stream #0:0: Video: theora, yuv444p, 600x600 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn
      Metadata:
        comment         : Cover (front)
        encoder         : Lavc61.19.100 libtheora
        TITLE           : Student Demonstration Time (Remastered 2009)
        ARTIST          : The Beach Boys
        GENRE           : Pop, Rock
        ALBUM           : "Feel Flows" The Sunflower & Surf’s Up Sessions 1969-1971
        album_artist    : The Beach Boys
        DATE            : 2021-08-27
        track           : 5
  Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp
      Metadata:
        encoder         : Lavc61.19.100 libopus
        TITLE           : Student Demonstration Time (Remastered 2009)
        ARTIST          : The Beach Boys
        GENRE           : Pop, Rock
        ALBUM           : "Feel Flows" The Sunflower & Surf’s Up Sessions 1969-1971
        album_artist    : The Beach Boys
        DATE            : 2021-08-27
        track           : 5

Theora is super lossy, and being stream 0 instead of stream 1 (as it originally was) confuses foobar2000 into refusing to tag the output files and foobar2000 not being able to display any album covers. When using its tagger to readd an album cover to audio files without an album cover, I get streams like this, which seem preferable:

  Stream #0:0: Audio: opus, 48000 Hz, stereo, fltp
      Metadata:
        ALBUM           : "Feel Flows" The Sunflower & Surf’s Up Sessions 1969-1971
        album_artist    : The Beach Boys
        ARTIST          : The Beach Boys
        DATE            : 2021-08-27
        encoder         : Lavc61.19.100 libopus
        GENRE           : Pop, Rock
        TITLE           : Student Demonstration Time (Remastered 2009)
        track           : 5
  Stream #0:1: Video: mjpeg (Progressive), yuvj444p(pc, bt470bg/unknown/unknown), 600x600, 90k tbr, 90k tbn (attached pic)
      Metadata:
        comment         : Cover (front)

Is there a way to automate converting, say, FLAC files to this format?

Check this: https://www.perplexity.ai/search/i-have-a-bunch-of-audio-files-fdRaS9ETQCajRI8I1d6Jzg

This is very wrong. The first command does not (and should not) do what it says it should do, and I need to extract the cover art file for each album manually while I wanted to automate it.

The idea behind me sending you that link is for you to see if you can find a way to work with it, or go directly to the sources and see what has been suggested.

What you are seeking to do is an edge case, so there may not be many people who have tried to do what you are trying to do.

It’s possible to figure it out with ffmpeg, but converting audio files is such a common task that we have good GUI apps for converting. So is ffmpeg a hard requirement?

PS: Personally I would recomend freac from the AUR.

Maybe, but also maybe not. Remember, it’s not just about converting. It’s mostly about converting while keeping the cover art or re-adding the cover art in a more or somewhat convenient way.

Usually these apps do that, they copy over cover-art and other meta-data (title, album, artist, year, …) from the original file.

Again, I’m not familiar with all of them of course, but for e.g. fre:ac does it just fine.

1 Like

I’m running a script to automate what I do after certain downloads. Freaccmd does convert well, thanks!

I do wonder if it’s possible to customize the output filename instead of having to move it after. The options are in the GUI but don’t appear to be in the CLI.

Another thing I’ve noticed is that the tool is much slower than FFMPEG’s conversions, but hey, I have time.

Unfortunately, this isn’t a complete solution. When foobar2000 tries to tag these .opus.ogg files from freac, it fails to add the ReplayGain tags (and somewhere in the process it messed up the disc and track numbers for some reason).

I’ve found the “official” opusenc tool within the opus-tools package to be my solution.

opusenc --bitrate 128 --vbr --ignorelength "$input-file" "$output-basename.opus.ogg"

It automatically embeds the cover art in the stream configuration I mentioned.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.