tag editing

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

tag editing

Grant Shoshin Shangreaux
Hello all,

working on getting my FSF assignment finished and looking forward to
contributing to the project soon.

I bumped into an issue when trying to edit tags for opus files, it
looked like it all worked fine, saved the metadata to the cache-db, but
there was no actual function defined to handle the opus format. so it
was a surprise to me to find that the files i tagged no longer had the
metadata the when i opened them in another program.

i'd like to fix that silent failure, but i also started digging around
for a solution for writing tags to all formats. unfortunately, there
isn't a simple tag writer included with the opus-tools package. you must
re-encode the audio to add tags. so far, i've found 3 candidates

  1. add a shim for TagLib to write to files (beyond me at the moment)
  2. opuscomment[1] tool (must be built from source)
  3. audiotools package's tracktag program[2]

I wrote a simple wrapper for tracktag that hooks into the tag-editor
code and have been testing that out. I'd be happy to share a patch, but
I can wait until the FSF assignment is done if that is better.

Another option might be to hook into the emms-info-native code and add
tag writing capabilities as well. I would be happy to collaborate on
that, but my time is somewhat limited. I do want to point out that
native tag writing capality would be really fantastic for my use of
EMMS. I record a lot of audio and have been hoping for a nice way to
author metadata using Emacs. I even gave a talk at emacs-conf demoing
how nice it was to use EMMS[3], not knowing my opus tags weren't even
being written xD.

Anyhow, please let me know if there's interest in the tracktag code, and
if there's any good way to help out otherwise.

best,
Grant Shangreaux


[1] https://github.com/hcmiya/opuscomment
[2] http://audiotools.sourceforge.net/tracktag.html
[3] https://emacsconf.org/2020/talks/05/

Reply | Threaded
Open this post in threaded view
|

Re: tag editing

Yoni Rabkin-2
Grant Shoshin Shangreaux <[hidden email]> writes:

> Hello all,
>
> working on getting my FSF assignment finished and looking forward to
> contributing to the project soon.

That is good to hear; thank you.

> I bumped into an issue when trying to edit tags for opus files, it
> looked like it all worked fine, saved the metadata to the cache-db, but
> there was no actual function defined to handle the opus format. so it
> was a surprise to me to find that the files i tagged no longer had the
> metadata the when i opened them in another program.
>
> i'd like to fix that silent failure,

This is a priority and would form a basis for all further tag editing
work. It would be great if you started there.

We would want that, if the tag editor is calling an executable, that a
failed process call would fail loudly.

Then we want that regardless of how the tags are being written, natively
or with an external process, that the editor would check if the tag had
indeed been updated in the file by comparing the tags in the file before
and after update. Trust, But Verify.

> but i also started digging around for a solution for writing tags to
> all formats. unfortunately, there isn't a simple tag writer included
> with the opus-tools package. you must re-encode the audio to add
> tags. so far, i've found 3 candidates

Re-encoding is a no-go.

>   1. add a shim for TagLib to write to files (beyond me at the moment)
>   2. opuscomment[1] tool (must be built from source)
>   3. audiotools package's tracktag program[2]

Packages such as audiotools are themselves abstractions to C libraries
such as libmpg123, libdvd-audio, etc. (like tinytag, which Emms calls).

We likely aren't going to ask to have any of those C libraries be linked
to Emacs on compilation, so the best scenario is indeed native reading
and writing, and that is a worthy goal.


--
   "Cut your own wood and it will warm you twice"

Reply | Threaded
Open this post in threaded view
|

Re: tag editing

Petteri Hintsanen-2
In reply to this post by Grant Shoshin Shangreaux
Grant Shoshin Shangreaux <[hidden email]> writes:

> Another option might be to hook into the emms-info-native code and add
> tag writing capabilities as well.

I wouldn’t recommend going this way, at least not yet.  Some rationale:

1. There are already plenty of solid free implementations for writing
   metadata, so this would be reinventing the wheel, and probably badly
   in comparison.

2. Writing to a file always carries the risk of messing up that file.
   Users would better have backups of their precious audio files.  This
   is true, of course, for all tag writing software, but especially so
   for a new implementation like this.

3. Adding support for writing tags is not straightforward as
   emms-info-native tends to cut corners due to its read-only nature.
   For example, it occasionally throws data away while decoding,
   including tags that EMMS does not recognize.  To prevent data loss,
   this ought to be fixed if the data would be written back at some
   point.

   Also, emms-info-native does not work with files that have multiple
   (multiplexed) streams.  It is questionable how many audio files do
   have more than one logical stream, but such files should be detected
   and any failures handled gracefully.

4. I’m looking forward to add MP3 (id3v2) support for emms-info-native
   but not more.  Support for MP4, for instance, is pretty complex to
   do.  With external tools we get much wider coverage for popular
   formats.  I personally don’t care for nonfree formats, but others
   may.

Personally I like the lightweight EMMS design that emphasizes the use of
external programs instead of (re)implementing stuff by itself.
Consequently, I see emms-info-native more like a simplistic stopgap
solution for those (hopefully rare) use cases where there are no
external metadata tools available or configured.  For any serious
metadata operations I would go with external tools.  In my own setups I
use emms-print-metadata and MPD, and MusicBrainz Picard for tagging.

This does not mean that emms-info-native couldn’t be a "simplistic
stopgap solution" for writing tags as well, but please consider the
caveats listed above.

Speaking of solutions,

> 1. add a shim for TagLib to write to files (beyond me at the moment)

this one is probably easy to do.  The current Taglib shim
(emms-print-metadata) can be extended to support tag updates as well.
I can help with that if needed.

Thanks,
Petteri

Reply | Threaded
Open this post in threaded view
|

Re: tag editing

Grant Shoshin Shangreaux

Petteri Hintsanen writes:

> I wouldn’t recommend going this way, at least not yet.

your insight is very much appreciated. i think all the points you
brought up are really important to consider.

> 1. There are already plenty of solid free implementations for writing
>    metadata

agreed, though I've not found a single executable that handles all the
formats and metadata at once. i think TagLib has the capability, and
audiotools tracktag is pretty close. oddly, tracktag does not write a
"genre" tag, which is one of the standard emms-info items.

> 2. Writing to a file always carries the risk of messing up that file.

yes, would be very sad to have EMMS destroy audio files. especially the
ones i'm working with which are originals. i often have backups, but
this is very important. i certainly don't want to be responsible for the
code that is doing it.

> 4. I’m looking forward to add MP3 (id3v2) support for emms-info-native
>    but not more.  Support for MP4, for instance, is pretty complex to
>    do.  With external tools we get much wider coverage for popular
>    formats.  I personally don’t care for nonfree formats, but others
>    may.

Another reason I started working with tracktag. I only cared about
adding metadata to opus, ogg, and flac, but having one interface that
can handle the other formats is a win for wider use.

> For any serious metadata operations I would go with external tools.
> In my own setups I use emms-print-metadata and MPD, and MusicBrainz
> Picard for tagging.

i agree. i had a sense that empowering emacs to do it would avoid some
of the hassle of setting up the external tools, but its really not that
hard. I built emms-print-metadata not realizing that it didn't support
tagging. i tried for a bit to work on the Taglib shim, but my lack of
time to hack and experience with C was blocking me.

>> 1. add a shim for TagLib to write to files (beyond me at the moment)
>
> this one is probably easy to do.  The current Taglib shim
> (emms-print-metadata) can be extended to support tag updates as well.
> I can help with that if needed.

That would be fantastic. I can continue with tracktag as well, it might
be useful since it is installable with a package manager for users who
might not go the length of compiling the emms-print/write-metadata
helpers. no rush on this, i've solved my immediate problem of writing
tags to opus files, but would be glad to contribute to any wider
solution!

Thanks,
Grant Shangreaux


Reply | Threaded
Open this post in threaded view
|

Re: tag editing

Yoni Rabkin-2
In reply to this post by Petteri Hintsanen-2

Petteri Hintsanen <[hidden email]> writes:

> 4. I’m looking forward to add MP3 (id3v2) support for emms-info-native
> but not more.  Support for MP4, for instance, is pretty complex to do.
> With external tools we get much wider coverage for popular formats.  I
> personally don’t care for nonfree formats, but others may.

Don't worry; we won't be adding support for non-free formats during my
tenure as maintainer.

--
   "Cut your own wood and it will warm you twice"