how can i get bitrate
of a MP3 File ?
The MP3 format can range from around 96 to 320Kbps, and streaming services like Spotify range from around 96 to 160Kbps. High bitrates appeal to audiophiles, but they are not always better. Keep in mind how your digital audio is going to have to contend with bottlenecks.
You can open the MP3 Encoding dialog from most places where you can select an output file format. For example, open an audio file, select File > Save As, click in the Format field, and select Edit. In the Audio File Format dialog, select MPEG-1 Layer 3 (MP3) as type, click the Encoding field, and select Edit.
The absolute lowest MP3 bit rate you should consider is 128kbps. This was often referred to as being CD quality, but it's far from being so. This bit rate will allow you to get much more music on to your MP3 player but you'll sacrifice a great deal of audio quality as a result.
MP3 Bitrate is stored in the 3rd byte of frame header so an option would be to search for the first byte with a value 255 (in theory there's should be no other bytes with all bits set to 1 before that) and bitrate should be stored two bytes after that. Following code does this:
program Project1;
{$APPTYPE CONSOLE}
uses
Classes, SysUtils;
const
BIT_RATE_TABLE: array [0..15] of Integer =
(0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0);
var
B: Byte;
begin
with TFileStream.Create(ParamStr(1), fmOpenRead) do begin
try
Position := 0;
repeat
Read(B, 1);
until B = 255;
Position := Position + 1;
Read(B, 1);
Writeln(BIT_RATE_TABLE[B shr 4]);
finally
Free;
end;
end;
end.
Note that this only finds bitrate of the first frame.
You can find more detailed info from here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With