How to remove amazons ID from mp3 files?

I have here thousands of mp3 files that I bought over the last years from amazon.
But I'm feeling not well by the fact that each track has inserted its own ID no.
So I want to remove these, but I won't destroy the mp3 file format.

Here a hexdump excertption from the end of a file.

0023c230  aa aa aa aa aa aa aa aa  aa aa aa aa aa aa aa 54  |...............T|
0023c240  41 47 45 70 69 6c 6f 67  75 65 00 00 00 00 00 00  |AGEpilogue......|
0023c250  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0023c260  44 61 67 6f 62 61 00 00  00 00 00 00 00 00 00 00  |Dagoba..........|
0023c270  00 00 00 00 00 00 00 00  00 00 00 00 00 00 54 61  |..............Ta|
0023c280  6c 65 73 20 6f 66 20 74  68 65 20 42 6c 61 63 6b  |les of the Black|
0023c290  20 44 61 77 6e 00 00 00  00 00 00 00 32 30 31 35  | Dawn.......2015|
0023c2a0  41 6d 61 7a 6f 6e 2e 63  6f 6d 20 53 6f 6e 67 20  |Amazon.com Song |
0023c2b0  49 44 3a 20 32 35 38 35  36 35 31 30 00 01 4f     |ID: 25856510..O|
0023c2bf


I tried to use the id3lib library (http://id3lib.sourceforge.net). But it seems that the TAG at the end of the file is not ID3v2.
Try an mp3 tag editor which has batch processing support.

For example, Mp3tag https://www.mp3tag.de/en/

It supports batch tag-editing of ID3v1, ID3v2.3, ID3v2.4, iTunes MP4, WMA, Vorbis Comments and APE Tags for multiple files at once covering a variety of audio formats.
...
Replace characters or words Replace strings in tags and filenames (with support for Regular Expressions).
Thanks, but your suggested tag editor supports only Windows and Mac (like almost all tag editors). In my repo I have yet a few tag tools which support batch processing at commando line. But I have not much experience writing nifty scripts on that. I fear that there could easily slip in an error which could compromise all files with one flush. So I want to code the stuff with C or C++, because with it I rather would know what I do.

It came at light to me, that the id3lib could handle also id3 tags at file end. So here a feasible solution that worked at all my files bought at amazon.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <id3/tag.h>
#include <iostream>
#include <filesystem>


void remove_comment( const std::filesystem::path & file )
{
    ID3_Tag tag( file.c_str() );

    bool frame_found = false;
    for( ID3_Frame * frame;  nullptr != (frame = tag.Find(ID3FID_COMMENT)); )
    {
        frame_found = true;
        tag.RemoveFrame( frame );
        std::cout << "File '"
                  << file.c_str()
                  << "' : ID3FID_COMMENT found, removed.\n"
        ;
    }
    if( ! frame_found )
    {
        std::cout << "File '"
                  << file.c_str()
                  << "' : no ID3FID_COMMENT found.\n"
        ;
        return;
    }

    tag.Update();
}

void process_files( const char * path )
{
    for( auto & dir_entry : std::filesystem::recursive_directory_iterator(path) )
    {
        if( ! dir_entry.is_regular_file() )
            continue;

        std::filesystem::path file = dir_entry.path();
        remove_comment( file );
    }
}


int main( int argc, char ** argv )
{
    if( argc < 2 )
        return 1;

    for( int i = 1; i < argc; ++i )
        process_files( argv[i] );

    return 0;
}



try making a copy of a couple and checking 2 things.


first, it may be in a fixed location, so you can just go there and zero (char zero) it out.
second, if its in a flexible location, you can find it (string search the text part) and zero it out that way.
After zeroing out your test files, see if they still work. It should be fine; this is very likely just block of bytes that allow text comments (or anything at all really) to be stuffed into it.
Non-programming approach:
Many sound cards have an option to turn on a sound loop so that musics/noises can be recorded as they play from your computer rather than from an external source. I know the option is not always available, so you'd have to do your own research on your card and what programs you have for your OS to manipulate it.

On linux the option is usually made available in alsamixer (the option is called Loopback) hit F6 to cycle through available sound cards. Turn your internal mic off, turn loopback on and recapture the song in audacity or with ffmpeg's recording device. It feels like this is today's version of creating a "mix tape" as the ancients once did.

Worth a try, since it's pure digital to digital I think you'd end up with a near perfect copy without any of the meta-data.

As for copyright laws, well, most copyright licenses also prohibit the modification of their media, so it's all gray area what you're trying to do. As long as you own an original copy and don't plan to distribute these files (like you're making a backup library for home use) then you're probably fine.

Edit: heh, just noticed you have posted your own answer. Nice code. I'll leave this up since I really like the idea of having a flushed out meta.
Last edited on
Just a note: the loopback recording device (generally labelled "Stereo Mix") listens behind the DAC, right in front of the line-out jack. It records something equivalent to plugging the line-out into the line-in, so it cannot produce a bit-perfect copy of the original stream.
Topic archived. No new replies allowed.