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
///cbr 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
//vbr 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
//abr 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 properties(on windows) still reads 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.
Learnt I have to write the
lametag
(which is gotten fromlame_get_lametag_frame
) to the file immediately after theid3v2
tags. This solved the challenge!NOTE:
lame_get_lametag_frame
is to be called after callinglame_encode_flush
, so you have to seek back to the end of theid3v2
tag to write thelametag
.