Skip to content

Enhancement Request: Preserve MP3 Metadata When Watermarking #56

Open
@tim-janik

Description

@tim-janik

Hi.
When using audiowmark to watermark an MP3 file, it successfully reads the MP3, adds the watermark but outputs the result as a WAV file, regardless of the file extension used as the output file name.
I.e. the resulting out.mp3 file with an MP3 extension actually contains WAV file data.
That behavior might be according to spec, but is quite surprising.
And, if the output file is a out.wav file, and e.g. lame is used to re-encode the WAV into MP3 data, the resulting MP3 file will lack the metadata from the original MP3, e.g. title, artist, album.

Here is the process I have come up with to preserve the metadata:

  1. Extract the metadata from the original MP3 using ffmpeg.
  2. Merge the extracted metadata into the re-encoded MP3 after watermarking into a WAV, using ffmpeg again.

The commands are:

ffmpeg -i input.mp3  -f ffmetadata metadata.txt
src/audiowmark add input.mp3 x.wav 0123456789abcdef0011223344556677 
lame x.wav x.mp3
ffmpeg -i x.mp3 -i metadata.txt -map_metadata 1 -codec copy output.mp3

It would be great if audiowmark could detect that the output file is supposed to be an MP3 file and handle the watermarking process in a way so that the output file is an MP3 with the original metadata intact and encoded with a bitrate similar to the input (some heuristics might be needed to guess the input bit rate). This would greatly improve usability and be less error prone than doing it all manually.

Regarding the WAV output even if the file extension is .mp3, I'd suggest to at least warn the user about the possible surprise and maybe require --force or similar, in case the user really wants that (which is highly unlikely).

To summarize:

  • Please catch WAV-in-MP3-file as output.
  • Ideally, re-encode MP3 output files.
  • Preserve metadata from input MP3 files when producing MP3 files.

If that is preferred, I could help with the creation of a wrapper script to achieve the above. (I just suspect that a standalone script couldn't support streaming mode really well...)

Thanks for consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions