1

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"
double-beep
  • 5,031
  • 17
  • 33
  • 41
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
  • Do you need to check the +35,000 files _every time_? Could you achieve a +2 hours process just one time (and store the results in a file), and from that time on just process the new files (and take old results from the file)? – Aacini Apr 26 '12 at 17:41
  • Thanks is a good idea but i thought about it, 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...). Bye – ElektroStudios Apr 26 '12 at 19:35
  • 1
    Why the downvote and the "close question"? This topic seems interesting to me! I am NOT the OP... – Aacini Apr 27 '12 at 01:06
  • at home i have a vbs that could do that, i'l look into it this evening. don't understand the part where you can't store the results cause of checked old files ??? must surely be possible. Ruby would be a lot better, if you need to obfuscate the code, there are ways, the decompressing you refer to is just once and the one sec this could take doesn't count in the time the whole process takes – peter Apr 27 '12 at 07:47
  • hi, no i don't need to ofuscate the code but need to convert it to exe for use it on other pc, so when the converted exe decompresses it takes a lot of time to check a lot of files... :(, I prefer a VBS to do it, PD: sorry for my english. – ElektroStudios Apr 27 '12 at 23:47
  • there are implementations of Ruby that have an auto install like the GUI Red Shoes, but the best were to just install ruby on these pc's, consider is a VM like eg Java. Anyway if you use VBS you will need a library also, dll, ocx or whatsoever and it will be more trouble installing these on other pc's. – peter Apr 28 '12 at 15:31

2 Answers2

2

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.

peter
  • 41,770
  • 5
  • 64
  • 108
2

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}
peter
  • 41,770
  • 5
  • 64
  • 108
  • hi, thankyou again but i can't find any gem called "audioinfo" :( – ElektroStudios May 07 '12 at 08:53
  • Just install ruby and once done, at the commandprompt Then cd to the \ruby193\bin map and type "gem install ruby-audioinfo" that's the way ruby libraries (gems) are installed. – peter May 07 '12 at 12:40