pythonmp3id3mutagen

How to corrupt mp3 files without altering general informations


I need to make some MP3 available on the internet for educational purpose. And I don't want it to be illegally downloaded. Thus I want to corrupt the MP3 files in such a way as to make them musically unreadable in other media players.

Problem:
I need to keep the metadata untouched (length, tags, etc) because I need to use mutagen.mp3 and mutagen.id3 on those MP3 files.

I did not try anything yet. I was wondering if anyone had an idea on how to do this?


Solution

  • It's been a long while (years) since I cared to work with MP3 bytes so double-check the frame-size numbers in my advice below. If you try something based on my guidance I can help fix any issues.

    note:
    Use a Hex editor to see the inside of an MP3 and follow the bytes structure as explained below.

    Possible solution:

    If your MP3 file has metadata then it's actually two sections joined up...
    (ie: ID3 metadata + MP3 audio data).

    ID3 editors only care about the first section so that part can be edited without affecting the audio.

    The first section is ID3 metadata which begins with 3 bytes of text "ID3" (or bytes: 49 44 33).
    It will have a size (bytes length) listed in the bytes, so you can skip past the ID3 to the start of MP3.

    The second section is MP3 data which begins with 2 bytes of numbers 255 251 (or bytes: FF FB).

    The two bytes FF FB are the typical start of an MP3 frame (MP3 frame header has 4 bytes eg: FF FB XX XX). The XX parts will depend on the MP3 settings like its frequency, bitrate, version, etc.

    To corrupt the MP3 data you could try: