Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Calculate the Kbps (kilobits per second) of a MP3 file.

Avatar of cunoc
cunoc asked on
JavaScriptHTMLPHP
17 Comments1 Solution881 ViewsLast Modified:
Hi all Experts,
Please help me with the math problem I have and thank you very much in advance.
---------------
Calculate the Kbps (kilobits per second) of a MP3 file.

If you have a 5 MB file with a length of 3 minutes, you would use the formular below to find out the Kbps (kilobits per second) of a MP3 file.

1K = 1024 bytes
1M = 1024K

1 hour   = 60 minutes
1 minute = 60 seconds

5MB = 5 * 1024 * 1024 bytes = 5242880 bytes

5242880 * 8 / 180 / 1000 = ~233 kbps
------------------

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE></TITLE>
<script type="text/javascript">
var Hour = 0;
var Minute = 3;
var Second = 0;

function F_Calculate_MP3_Bitrate_Forward ()
{
   var i = parseFloat(document.getElementById('Calculate_MP3_Bitrate_Forward').value);
   var m = "";

   if (!isNaN(i)) m = Math.ceil(((i * 1024 * 1024) * 8 / ((Hour * 3600) + (Minute * 60) + (Second * 1)) / 1000) / 1024 / 1024);
      document.getElementById('Calculate_MP3_Bitrate_Reversed').value = m;
}

function F_Calculate_MP3_Bitrate_Reversed ()
{
   var i = parseFloat(document.getElementById('Calculate_MP3_Bitrate_Reversed').value);
   var m = "";
   if (!isNaN(i)) m = Math.ceil(((i * 1024 * 1024) / 8 * ((Hour * 3600) + (Minute * 60) + (Second * 1)) * 1000) / 1024 / 1024);
      document.getElementById('Calculate_MP3_Bitrate_Forward').value = m;
}

function setbitrate_Hour(in_hour)
{
   Hour = in_hour;
}

function setbitrate_Minute(in_minute)
{
   Minute = in_minute;
}

function setbitrate_Second(in_second)
{
   Second = in_second;
}

</script>

</head>

<body>
<br />
<center>

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="98%">
<tr>
<td width="40%">
  <label><input id="Calculate_MP3_Bitrate_Forward" onKeyUp="F_Calculate_MP3_Bitrate_Forward()"/><font color="#000000" face="Tahoma" style="font-size: 8pt">&nbsp;File Size (MB)</font></label>
</td>

<td <td width="20%"><select name="Hour" id="Hour" onchange="setbitrate_Hour(this.options[this.selectedIndex].value);">
<option value="0" selected="selected">0 hour</option>
<option value="1">1 hour</option>
<option value="2">2 hours</option>
</select>
</td>


<td <td width="20%"><select name="Minute" id="Minute" onchange="setbitrate_Minute(this.options[this.selectedIndex].value);">
<option value="1">1 minute</option>
<option value="2">2 minutes</option>
<option value="3" selected="selected">3 minutes</option>
<option value="4">4 minutes</option>
<option value="5">5 minutes</option>
<option value="6">6 minutes</option>
<option value="7">7 minutes</option>
<option value="8">8 minutes</option>
<option value="9">9 minutes</option>
<option value="10">10 minutes</option>
<option value="11">11 minutes</option>
</select>
</td>


<td <td width="20%"><select name="Second" id="Second" onchange="setbitrate_Second(this.options[this.selectedIndex].value);">
<option value="0" selected="selected">0 Second</option>
<option value="1">1 Second</option>
<option value="2">2 Seconds</option>
<option value="3">3 Seconds</option>
<option value="4">4 Seconds</option>
<option value="5">5 Seconds</option>
<option value="6">6 Seconds</option>
<option value="7">7 Seconds</option>
<option value="8">8 Seconds</option>
<option value="9">9 Seconds</option>
<option value="10">10 Seconds</option>
<option value="11">11 Seconds</option>
</select>
</td>


<td width="30%">
  <label><input id="Calculate_MP3_Bitrate_Reversed" onKeyUp="F_Calculate_MP3_Bitrate_Reversed()"/><font color="#000000" face="Tahoma" style="font-size: 8pt">&nbsp;(Kbps)</font></label>
</td>

</tr>
</table>

</center>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Commented:
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answers