用LAME编码的MP3的长度 [英] Length of MP3 encoded with LAME

查看:415
本文介绍了用LAME编码的MP3的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用LAME编写pcm到mp3的编码,但生成的mp3的长度更长(并且能够隔离导致此问题的部分代码)。 pcm大约是4:45但是当我用设置编码时



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



结果mp3长度约为11:30



当我使用设置进行编码时



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



得到的mp3长度约为14:18



但是当我用设置编码时



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



得到的mp3长度正确4:45(但我注意到当我将比特率增加到188时,长度跳跃大约5秒到4:50)





我真的不知道出了什么问题,但似乎只有abr才能产生合适的长度vbr和cbr不是!



UPDATE ::::

当这些mp3播放时,它们正常播放并在4:45停止但Windows媒体播放器及其属性(在Windows上)仍在阅读上述长度



UPDATE :::通过删除lame_set_preset设置使cbr设置正常工作。这只是vbr设置返回不正确的长度

解决方案

据悉我必须写 lametag (这是从 lame_get_lametag_frame 获得 id3v2 标签后面的文件。这解决了挑战!



注意:

lame_get_lametag_frame 将在之后调用调用 lame_encode_flush ,所以你必须回到 id3v2 标签的末尾才能写出 lametag

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

解决方案

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.


这篇关于用LAME编码的MP3的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆