A modo de curiosidad les dejo el recorte de un codigo que adapte , su autor original es Lazycat o Cape-City. He descartado este enfoque ademas de que no entiendo muy bien su funcionamiento por su lentitud.
Código: Seleccionar todo
Func BitrateAlternativo ($r,$n)
Local $offset = 1, $isVBR = 0 , $sBitrate = ""
$Archivo=$ruta&"\"&$nombre
If _FileReadAtOffsetHEX ($Archivo, 1, 3) = "494433" Then; ID3v2 tag found
$offset = BitShift(Dec(_FileReadAtOffsetHEX ($Archivo, 7, 4)), 1); End of ID3v2 tag
Endif
For $ic = $offset to 2048 + $offset
$marker = _FileReadAtOffsetHEX ($Archivo, $ic, 2)
$marker = StringLeft($marker, 3)
If StringInStr("FFF,FFE", $marker) Then; Assume that is frame start
$frame = _FileReadAtOffsetHEX ($Archivo, $ic, 4)
If _FileReadAtOffsetHEX ($Archivo, $ic+36, 4) = "58696E67" Then $isVBR = 1; Is this a right way?..
Exitloop
Endif
Next
If $frame = "" Then
SetError(1); Frame not found (not mp3 data?)
Return
Endif
Local $head = _HexToBin($frame)
Local $nVer = _GetRBits($head, 19, 2)
Local $nLay = _GetRBits($head, 17, 2)
Local $pad = 0
;~ Local $bitrate
If _GetRBits($head, 9, 1) Then $pad = 1
If $isVBR Then
$BRT = "-1"
Else
Select
Case $nVer = 3 and $nLay = 3
Dim $Bitrate[16] = ["-1","32","64","96","128","160","192","224","256","288","320","352","384","416","448""-1"]
Case $nVer = 3 and $nLay = 2
Dim $Bitrate[16] = ["-1","32","48","56","64","80","96","112","128","160","192","224","256","320","384""-1"]
Case $nVer = 3 and $nLay = 1
Dim $Bitrate[16] = ["-1","32","40","48","56","64","80","96","112","128","160","192","224","256","320""-1"]
Case $nVer = 2 and $nLay = 3
Dim $Bitrate[16] = ["-1","32","48","56","64","80","96","112","128","144","160","176","192","224","256""-1"]
Case ($nVer = 2 and $nLay = 2) or ($nVer = 2 and $nLay = 1)
Dim $Bitrate[16] = ["-1","8","16","24","32","40","48","56","64","80","96","112","128","144","160""-1"]
EndSelect
$BRT = _GetData($Bitrate, _GetRBits($head, 12, 4))
Return $BRT
EndIf
EndFunc
Func _GetRBits($str, $pos, $size)
Local $ic, $res = 0, $bStr = StringMid($str, 33 - $pos - $size, $size)
For $ic = 0 to $size-1
If StringMid($bStr, $size-$ic, 1) == "1" Then $res = $res + 2^$ic
Next
Return ($res)
EndFunc
Func _GetData(ByRef $array, $val)
If $val > UBound($array)-1 Then Return("Undefined")
Return ($array[$val])
EndFunc
Func _HexToBin($str)
Local $res=""
While StringLen($str) > 0
$val = Dec(StringLeft($str, 1))
$str = StringTrimLeft($str, 1)
For $i = 3 to 0 Step -1
$pw = 2^$i
If $val - $pw < 0 Then
$res = $res & "0"
Else
$res = $res & "1"
$val = $val - $pw
Endif
Next
Wend
Return ($res)
EndFunc
Func _FileReadAtOffsetHEX ($Archivo, $offset, $bytes)
Local $tfile = FileOpen($Archivo, 0)
Local $tstr = ""
FileRead($tfile, $offset-1)
For $i = $offset To $offset + $bytes - 1
$tstr = $tstr & Hex(Asc(FileRead($tfile, 1)), 2)
Next
FileClose($tfile)
Return ($tstr)
Endfunc