Search code examples
javatagsmetadataopus

How Can I Add Metadata in opus files?


I'm interested in writing metadata for .opus files, but all of the posts that I've seen so far are for more mainstream formats such as .ogg, or .mp3. I'm uncertain as to whether ID3 tags work with .opus files, and I can't find any resources that say whether they do or not. I've seen something similar in (How to add metadata to WAV file?).

How can I write metadata such as title, author, and the like to .opus files?

I'm thinking that a libopus enabled ffmpeg would be able to do it, but from the documentation it is not obvious to me how to do it.

Solutions using just ffmpeg are preferred, but any open source Java library should be just fine as well.


Solution

  • If you are encoding an existing audio file to opus, then it is easy to do using opusenc:

    opusenc input.wav out.opus --title "This is a title" --artist "The Beatles"

    There are several metadata options

     --title title      Set track title
     --artist artist    Set artist or author, may be used multiple times
     --album album      Set album or collection
     --genre genre      Set genre, may be used multiple times
     --date YYYY-MM-DD  Set date of track (YYYY, YYYY-MM, or YYYY-MM-DD)
     --comment tag=val  Add the given string as an extra comment
                          This may be used multiple times
     --picture file     Attach album art (see --help-picture)