Skip to content Skip to sidebar Skip to footer

How To Change Header Info In Mp3 File?

Below are my queries. 1.What information is there in header field of mp3 file? 2.If i need to change like bitrate,length,is it possible to change programatically. 3.Is it necessary

Solution 1:

  1. See ID3 or MP3 file structure if that's missing from the file.
  2. You can't change something like the bitrate without re-encoding the audio stream. You can change information in the ID3 like song title and artist.
  3. No, however you'll unlikely find many without one these days.
  4. Depends on what you do to the file. If you just change information in the ID3 I'm not sure that you can actually make it unplayable (though likely if you corrupt it such that it's not a recognized ID3 header it won't play).

You'll probably want to take a look at the Java ID3 Tag Library.

Update: In your comment you said you just want to be able to make it so an mp3 can't be played and then have the ability to reverse it. In that case you could just XOR some bytes in the file with some value to make it unplayable. Then repeat the process with the same value for the same bytes and it'd be returned back to normal. Here's an example of XOR'ing the first 65536 bytes with 34:

RandomAccessFile raf = new RandomAccessFile("my.mp3", "rw");
byte[] buf = newbyte[65536];
intlen = raf.read(buf);
for (int i = 0; i < len; i++) {
    buf[i] ^= 34;
}
raf.seek(0);
raf.write(buf);
raf.close();

This makes the mp3 unplayable for me. Repeating it makes it playable again.

Post a Comment for "How To Change Header Info In Mp3 File?"