Question

I need to check the bitrate of a music file, I need to receive the number in digits like: 192000 (for 192 kbps), 320000 (for 32kbps) or (+)3000000 for wavs and uncompressed music. I mean I need exactly the number, If an MP3 is VBR and is compressed at 194 kbps, I need the 194000 number, not the current CBR 192000.

I was do this job with MEDIAINFO (x64) CLI Program, In Batch:

for /f "tokens=*" %%%% in ('mediainfo "%%a" "--Inform=General;%%BitRate/String%%"') do set "BitRate=%%~%%"

But I have 35.000+ files to check and then the comprobation of all files is more than 2 hours of time.


I need a simple code to check it, Not a program which need to execute it and to waste that lot of time...

Is very important that the code needs to recognize at least this filetypes (I mean the internal bitrate): AIFF, FLAC, M4A, MP3, OGG, WAV, WMA.

And can't be a code for Ruby or Python, because I'll need to "compile" it and sure when is "compiled" waste a lot of time to check much files (Cause the uncompression of the .exe compiled).

More info: I thinked about store the results in a file and then do a comparision to chek only new added files, But I can't store the result to do a comparision at the next run cause sometimes I'll need to replace checked files (old files). By the way neither I can't handle this by file datestamps. Need to be one unique procediment to check ALL the files, Ever (Or this is what I think...).


I tried another method to check the bitrates, I'm really sure this is what I need but I can't get it run like I want...

This VBS uses the DBPowerAmp program API, And shows a window with info (included the bitrate), But with a window I can't do nothing... Maybe if I can redirect the windows info to a text file... And then set the variable "Bitrate" by reading the bitrate info in the text file... But I don't know how to do that:

' create shell object
Set WshShell = CreateObject("WScript.Shell")

' Create dMC Object
Set dMC = CreateObject("dMCScripting.Converter")

'Read audio properties of a file
Dim AudioProps
AudioProps = dMC.AudioProperties("C:\test.aac")
Call WshShell.Popup(AudioProps, , "Returned Audio Properties", 0)

I've tried to "convert" that code into Batch, like this, But don't run, I get nothing:

@echo off
rundll32.exe dMCScripting.Converter.AudioProperties("C:\Test.aac") > test.txt
exit

Oh and I've tried this too, but waste more time than mediainfo:

mplayer "test.aac" -frames 0 | findstr "kbit"
Was it helpful?

Solution

To give you an idea of what it is like in Ruby, audioinfo is just one of the many libraries doing such things.

require "audioinfo"

AudioInfo.open("R:/mp3/j/John Coltrane - I Think.mp3") do |info|
  puts info.to_h
end
=>{"artist"=>"John Coltrane", "album"=>"John Coltrane", "title"=>"I Think", "tracknum"=>nil, "date"=>nil, "length"=>272, "bitrate"=>128}

OTHER TIPS

Here a vbs script, works with mp3, the rest i didn't try

Set objPlayer = CreateObject("WMPlayer.OCX" )
Set colMediaCollection = objPlayer.mediaCollection

Set colMedia = colMediaCollection.getAll()

For i = 0 to colMedia.Count - 1
    Set objItem = colMedia.Item(i)
    Wscript.Echo objItem.Name & " : " & objItem.GetItemInfo("bitrate")
Next

See http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/OLE~COM~ADO~CDO~ADSI~LDAP+Get~Audio~File~Information.txt for a list of attributes you can use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top