Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Manipulate displayed mp3 track length (Read 5664 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Manipulate displayed mp3 track length

Hello

I want to change the track length that is displayed by windows or an audio player for a given .mp3 file. As I understand, the track length is calculated from information that is stored in the frame header(s). Is there a way to change some or all headers in such a way that a different track length is displayed?

I remember that from time to time I used to see an odd mp3 file that displayed the wrong track length for some reason (probably linked to VBR encoding), but which could still be played without a problem. If there was a way to replicate this type of "malfunction" this would be great and exactly what I needed...

Thanks a lot!

Gus

Re: Manipulate displayed mp3 track length

Reply #1
I don't know all of the details about the MP3 format (or where to find them) but maybe I can get you started -

A Hex Editor is a programmer's tool that allows you to view and the bytes of ANY file (as hex data). 

And, will show you the ASCII characters for any values that happen to represent alphanumeric characters.   For example, 4C (hex) = 76 (decimal) can represent an upper case "L".  That doesn't mean everywhere you find 4C it represents "L".  It could be audio data, etc., but you can search for the string "LAME" or the string "xing".   (The XING header may contain the playing time information that you want to corrupt but I also think there is a VBR header that's related.)

Note that the ASCII value for an alphanumeric digit is different from it's actual hex or decimal numerical value and I don't know if playing time is represented as a hex value or as ASCII digits (and I don't know if it's seconds or minutes & seconds, etc.).  For example, when I search for "LAME", I found "LAME3.98" and the "3" is represented in ASCII as 33 hex (51 decimal), not as 03 hex.

P.S.
Here is some more information. 

And I forgot to mention - The Windows Calculator in Programmer Mode can convert between hex and decimal.

 

Re: Manipulate displayed mp3 track length

Reply #3
Thanks @DVDdoug and @saratoga! With your hints, I was able to successfully modify the xing header of a Lame encoded VBR mp3 file. Changing the corresponding bytes of the number of frames, lead to an mp3 file which showed a track duration according to:

Duration = Number of Frames * Samples Per Frame / Sampling Rate

with the file still being correctly played. This seems to work for winamp, vlc player and windows in general. Unfortunately, it does not seem to work for the proprietary software I have to use. When using that software, somehow the original track duration is identified.

Any other ideas on how the track duration could be calculated resp. fooled into displaying an arbitrary value?

Thanks a lot!
Gus

Re: Manipulate displayed mp3 track length

Reply #4
If this is a CBR file it won't need the VBR header.  If it is VBR, it could be reading a different header, or estimating it from the average bitrate of the start of the file (this will typically be inaccurate however).

Re: Manipulate displayed mp3 track length

Reply #5
The file I tested was a vbr file. And changing the xing header seemed to do the trick, at least for winamp and vlc...

I also tried changing the bit rate in the frame headers of a cbr file (e.g. from 192kb/s to 96kb/s), but that was not very successful: Winamp played the file with some sound hiccups and still showed the original duration while the proprietary software didn't even recognize it as valid sound file anymore.

I have no clue what the software does to figure out the track duration. If it really estimates the duration by some averaging method, then it is not that bad. For a ~3min track it got the track length correct to the second...

Do you have any suggestions which header or entries I could try to modify in order to achieve what I want?

Re: Manipulate displayed mp3 track length

Reply #6
Is another VBR header present in the file?

Re: Manipulate displayed mp3 track length

Reply #7
I did not find a VBRI header. Are there any others I could look for?

I am thinking that If the software goes through the file frame by frame to determine average bit rate and number of frames then the only way would be to manipulate the mpeg audio frame headers. This would also work for cbr encoded files then. Any idea on how that might work?

Re: Manipulate displayed mp3 track length

Reply #8
Quote
am thinking that If the software goes through the file frame by frame to determine average bit rate and number of frames then the only way would be to manipulate the mpeg audio frame headers.
From what I understand, some software works that way and it should be foolproof unless the file is badly corrupted.  I'm pretty sure that's how "MP3 repair" tools work.

But, that means it has to read the and analyze entire file before it can determine playing time.    With long MP3s that could cause a significant delay so most player software just reads the file as it's playing.

Re: Manipulate displayed mp3 track length

Reply #9
Hm, but then the question still remains: Is there a way to manipulate multiple frame headers of a file (either cbr or vbr encoded) in such a way that the calculated track length is concealed?

Re: Manipulate displayed mp3 track length

Reply #10
Hm, but then the question still remains: Is there a way to manipulate multiple frame headers of a file (either cbr or vbr encoded) in such a way that the calculated track length is concealed?

Assuming your software reads those headers, yes.  If it does not read them and instead steps through the file, then no.