Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am currently working on the encoding of pcm to mp3 using LAME but the length of the resulting mp3 is longer (and was able to isolate the part of the code causing this). The pcm is about 4:45 but when I encode with settings

lame_set_VBR(gfp, vbr_off);
lame_set_quality(gfp, 5);
lame_set_preset(gfp, 128);

the resulting mp3 length was about 11:30

when I encode with settings

lame_set_VBR(gfp, vbr_mtrh);
lame_set_VBR_quality(gfp, 5);

the resulting mp3 length was about 14:18

but when I encoded with settings

lame_set_VBR(gfp, vbr_abr);
lame_set_VBR_min_bitrate_kbps(gfp, 128);

the resulting mp3 length was correctly 4:45 (but I noticed when I increased the bitrate to 188, the length jumped up about 5sec to 4:50)


I dont really know what am doning wrong but it seems only abr is resulting the right length vbr and cbr are not!

UPDATE::::
when these mp3 are played, they played normal and stopped at 4:45 but the windows media player and their property(on windows) still reading those above lengths

UPDATE::: got the cbr settings working by removing the lame_set_preset settings. It's only the vbr settings that is returning incorrect length
Posted
Updated 30-Aug-13 7:51am
v3
Comments
KarstenK 28-Aug-13 9:11am    
from what are you getting that info? Windows is guessing sometimes about mp3...
Oso Oluwafemi Ebenezer 28-Aug-13 12:45pm    
Windows Media Player and the property tab on Windows
KarstenK 29-Aug-13 2:07am    
I wont really on that. I guess M$ is dividing size / bitrate also if it is VBR. And so on...

Check a better way. May look with winamp.
Oso Oluwafemi Ebenezer 30-Aug-13 13:55pm    
I think it has to do with my settings. When I prayed the mp3 on vlc too, the total length keep going up and down for some time until it settled on the correct time.

1 solution

Learnt I have to write the lametag (which is gotten from lame_get_lametag_frame) to the file immediately after the id3v2 tags. This solved the challenge!

NOTE:
lame_get_lametag_frame is to be called after calling lame_encode_flush, so you have to seek back to the end of the id3v2 tag to write the lametag.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900