fmang / opustags

Ogg Opus tags editor
BSD 3-Clause "New" or "Revised" License
82 stars 11 forks source link

[Question]How can I add a cover to an opus file ? #50

Closed sebma closed 1 year ago

sebma commented 3 years ago

Hi,

How can I add a cover to an opus file ?

fmang commented 3 years ago

I don’t think it’s something specific to Opus, but more like a convention followed by most of Xiph’s formats. See https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE

opustags does not generate that tag, but if you dump the base64 data as a regular comment it should work. Note however that opustags does not currently support tags exceeding 64kB.

I saw your question on Stack Overflow (https://superuser.com/questions/1385109/add-album-art-cover-to-an-ogg-opus-file-from-the-command-line). How about trying hackerb9’s answer to generate a recoded Opus with the right tags using opusenc, then reproducing the tags from the recoded file to the original one using opustags? The command for reproducing tags is opustags merged.opus | opustags -S audio.opus -o final.opus. Though that solution is quite wasteful, the result should be just right.

Maybe someday opustags will support cover arts. Someone once hacked opustags for that, see https://github.com/fmang/opustags/pull/21.

sebma commented 3 years ago

@fmang Thanks a lot. I'll look into it.

iconoclasthero commented 3 years ago

I'm interested in this as a future option.

shmerl commented 1 year ago

This fork had a feature for adding a cover, but it was deleted: https://github.com/zvezdochiot/opustags

I saved the repo though, so there is an example how it can be done.

zvezdochiot commented 1 year ago

@shmerl say:

but it was deleted: https://github.com/zvezdochiot/opustags

https://github.com/Sound-Linux-More/libopustags

shmerl commented 1 year ago

Oh, thanks for the pointer!

shmerl commented 1 year ago

Would it make sense to merge these projects since opustag is active now too? Adding a cover was a really hard to do operation for opus files when last time I tried, until I found that fork.

zvezdochiot commented 1 year ago

@shmerl say:

Would it make sense to merge these projects since opustag is active now too?

Opustags writes multi-page meta correct. In libopustag, multi-page metas are written with a small error == warning. But I can't stand C++, so there won't be any merging under any pretext.

See also: #58

fmang commented 1 year ago

My recent works on 1.7.0 for supporting multi-page headers made support for cover arts one step closer. I’ve just added --set-cover and --output-cover in the master branch if anyone would like to try. I will probably release the feature by the end of the month.

mrfragger commented 2 days ago

to add with ffmpeg is really hard....must rely on opustags to get the accurate base64 data

opustags --output-cover cover.png some.opus then decoding just the top portion shows RDF metadata

������ image/png����������������������HىPNG  ��� IHDR��������}V���gAMA�� a��� cHRM��z&���������u0��`��:��pQ<���eXIfMM�*������������������J�������R(�������i�������Z�������H������H������������������������������� pHYs�� �� ���iTXtXML:com.adobe.xmp�����

72 2 72 1 1689 1 720 ffmpeg -y -i some.opus -i out.opus.ffmetadata -map_chapters 1 -map 0:a -metadata:s:a METADATA_BLOCK_PICTURE="$(cat ~/.config/mpv/extrastuff/base64.txt)" -c copy meta.opus ; ffprobe meta.opus Stream #0:1: Video: png, rgb24(pc, gbr/unknown/unknown), 1280x720, 90k tbr, 90k tbn (attached pic) Metadata: comment : Cover (front) title : Front cover anyway the original png 1280x720 black image is 3KB....if I used freac or kid3 and even opustags to add coverart then I can get the compliant base64 decoded image with necessary RDF metadata evidently. You can also just paste in the metadata instead of keeping a file ffmpeg -i "$bname.opus" -i $metafile -map_chapters 1 -map 0:a -metadata:s:a METADATA_BLOCK_PICTURE="AAAAAwAAAAlpbWFnZS9wbmcAAAALRnJvbnQgY292ZXIAAAUAAAAC0AAAABgAAAAAAAAOLYlQTkcNChoKAAAADUlIRFIAAAUAAAAC0AgCAAAAQB9KAQAAAaV6VFh0UmF3IHByb2ZpbGUgdHlwZSBleGlmAAB42qVUWXLDIAz91yl6BLQY8HEcG2Z6gx6/Twp27TSdZlppAPlJaCWh9vHe6c0pl0Q2lZrnnBPIZptlgVDTnVy+YcmQXZXTTpzm2IMIaxrwRbHdryeWK76fvDw4shGdb1fFjkt9cCT3Qz0AZLbhaN4DKeAnkfNcS7Kv72Vc7MPhBItSJZGqNBVfHkV9mS44K/bwDkQhayCq7jD6hKjFUx8ZxVWBmmc+KyJxHR0/4bCHe40mXZt91H5VHEPQK74dXRqUwztTROUT+GQirwyEnk0kyjo12HZJrvhUv/KnmEDfau8tLGyxjIeZx8va58fDDs/TNMpWuHRWyDgJ2xSc0dIVb7oM7njTN+S7MqfOAvbTSTnzygWn8c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