-2

So there are a few questions about reading out there but none really properly answered it as to how one goes about taking a MP3 file of unknown characteristics and extracting the information about the bitrate(s) contained in the file, as well as how to find said frames in the file.

Some of the existing question which were similar in nature were answered with links to other websites that don't exists anymore. Or the content which was linked to no longer exists.

The closest I find is the technical documents over on http://www.mp3-tech.org/ with the guide for "MPEG Audio Layer I/II/III frame header" but then I also need to work around anything in the MP3 file which is not an audio frame so I seem to be needing information on locating that as well.

Colin
  • 47
  • 4

1 Answers1

3

If you look for a VBA function you could use the Microsoft Shell Controls And Automation library

Function getBitrate(ByVal sPath As String) As Variant
' Reference to "Microsoft Shell Controls And Automation" is needed
    Dim objShell As Shell32.Shell
    Dim objFolder  As Shell32.Folder
    Dim objFolderItem As Shell32.FolderItem
        
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(Left(sPath, InStrRev(sPath, "\") - 1))
    Set objFolderItem = objFolder.ParseName(Mid(sPath, InStrRev(sPath, "\") + 1))
    
    getBitrate = objFolder.GetDetailsOf(objFolderItem, 28)
    
End Function

Test it with

Sub Test()

 Dim sPath As String
 sPath = "d:\Music\filename.mp3"
 Debug.Print "Bitrate: ", getBitrate(sPath)

End Sub

Further reading

Storax
  • 11,158
  • 3
  • 16
  • 33
  • This is ultra platform dependent making not portable. The GetDetailsOf method changes from version to version and in some cases depends on what other software is installed to permit the shell to retrieve the information desired. I have seven different computers here and it only works on one. – Colin Aug 12 '22 at 16:48
  • As said it is for VBA and Windows. I suggest you improve your question and tell us what are you looking fot, what you have tried so far and where you got stuck. It would also be helpful to know on what kind of computers you tried and where it failed and what kind of error you got. It does not really help that you have got seven differerent computers and just tell in general it does not work. – Storax Aug 12 '22 at 16:53
  • There is no error message, you get back an empty result. – Colin Aug 13 '22 at 17:46
  • It would be nice to get more details. I also asked for more meanigful information. But, of course, that's up to you. Good Luck – Storax Aug 13 '22 at 17:51
  • There is no error message, you get back an empty result. The various machines are W10's, W7's, and W2K server lurking in the network only accessible via VNC. `GetDetailsOf.[28] = Bit rate` versus `GetDetailsOf.[22] =Bit Rate` so you would need to know what platform you are on to get the results you desire plus any security issues from scripting the shell. – Colin Aug 13 '22 at 17:53