根据比特率和文件大小计算Mp3持续时间 [英] Calculate Mp3 duration based on bitrate and file size

查看:741
本文介绍了根据比特率和文件大小计算Mp3持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过使用比特率和文件大小来计算mp3持续时间,经过一番搜索后,我发现此公式:

I try to calculate mp3 duration by using bitrate and file size , after some search i found this formula:

(mp3sizeInByte*0.008)/bitrate

我正在使用mp3sizeInByte*0.008将字节转换为千位.

i am using mp3sizeInByte*0.008 to convert byte to Kbits.

但准确度不高,结果与实际mp3持续时间相比,相差几秒钟.

but its not so accurate , in result there is couple second different compare to actual mp3 duration.

我想知道这个正确的公式吗?

i want know this right formula ?

推荐答案

您可以使用以下公式计算大小:

You can calculate the size using the following formula:

x =歌曲长度(以秒为单位)

x = length of song in seconds

y =每秒千比特率

(x * y)/8

我们用8除以得到千字节(kb)的结果.

We divide by 8 to get the result in kilobytes(kb).

例如,如果您有一首3分钟的歌曲

So for example if you have a 3 minute song

3分钟= 180秒

128kbps * 180秒= 23,040千位数据 23,040 kb/8 = 2880 kb

128kbps * 180 seconds = 23,040 kilobits of data 23,040 kilobits / 8 = 2880 kb

然后您将被1024除以转换为兆字节:

You would then convert to Megabytes by dividing by 1024:

2880/1024 = 2.8125 Mb

2880/1024 = 2.8125 Mb

如果所有这些都是以不同的编码速率完成的,则说192kbps,它看起来像这样:

If all of this was done at a different encoding rate, say 192kbps it would look like this:

(192 * 180)/8 = 4320 kb/1024 = 4.21875 Mb

(192 * 180) / 8 = 4320 kb / 1024 = 4.21875 Mb

这篇关于根据比特率和文件大小计算Mp3持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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