0

I have a large collection of music and would like to know the bit rate and bit depth of the individual files. What is the simplest/easiest way to achieve this?

EDIT FOR ADDED DETAILS: I am using Windows 10 and it does not show properties of all the files in folders (there is no way to 'expand' a folder as on a mac when in detail view). I know how to add the bit depth label and bit rate label to a window when I open the folder to view the files in it. But I need to find all files for example that have a bit depth of 24 bits in a set of nested folders that contain many music files : some 16 bit and some 24 bit. The goal of this exercise is to segregate all files> 16 bits to another directory.

I tried using mp3 tag, an application that lists these properties for all files in a directory (even those deeply nested) but it is agonizingly slow on my laptop (30000 files would take 5 hours just to list). I tried using mediainfo (from mediaarea.net) but it only works on individual files. I tried mapping the network folder (where the files exist) and using the 'tree' command but it does not work either. A google search for 'recursively list bit rate of all files in windows' gave a few links one of which was 11 years old here. I modified it for flac like so

function Get-FLACs( [string]$directory = "$pwd", [int]$minimumBitrate = 32 ) {
  $shellObject = New-Object -ComObject Shell.Application
  $bitrateAttribute = 0

  # Find all flac files under the given directory
  $flacFiles = Get-ChildItem $directory -recurse -filter '*.flac'
  foreach( $file in $flacFiles ) {
    # Get a shell object to retrieve file metadata.
    $directoryObject = $shellObject.NameSpace( $file.Directory.FullName )
    $fileObject = $directoryObject.ParseName( $file.Name )
    Write-Output ("filename",$fileObject)

      # Find the index of the bit depth attribute, if necessary.
      for( $index = 5; -not $bitdepthAttribute; ++$index ) {
        $name = $directoryObject.GetDetailsOf( $directoryObject.Items, $index )
        if( $name -eq 'Bit depth' ) { 
          $bitdepthAttribute = $index 
          Write-Output ("bit depth index",$bitdepthAttribute)
          $bitdepthString = $directoryObject.GetDetailsOf( $fileObject, $bitdepthAttribute )
          Write-Output ("bit depth",$bitdepthString)
          }
      }
    }

I tried to test the above script on a folder with 2 flac files both of which are 24 bit depth and 96 khz sample rate.

The output of the script above was

       Directory: C:\Users\Stefan\Downloads\Compare formats
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        6/15/2014  11:27 PM       66131611 BATIK - The Old Man FLAC.flac
    174
    
    -a----        4/26/2014   8:41 PM       34188974 Carmen Gomes Inc - A 1000 Shades of Blue FLAC.flac

PS C:\Users\Stefan\Downloads\Compare formats> Get-FLACs
filename


Application  : System.__ComObject
Parent       : System.__ComObject
Name         : BATIK - The Old Man FLAC
Path         : C:\Users\Stefan\Downloads\Compare formats\BATIK - The Old Man FLAC.flac
GetLink      :
GetFolder    :
IsLink       : False
IsFolder     : False
IsFileSystem : True
IsBrowsable  : False
ModifyDate   : 6/15/2014 11:27:46 PM
Size         : 66131611
Type         : FLAC File

bit depth index
174
bit depth

filename
Application  : System.__ComObject
Parent       : System.__ComObject
Name         : Carmen Gomes Inc - A 1000 Shades of Blue FLAC
Path         : C:\Users\Stefan\Downloads\Compare formats\Carmen Gomes Inc - A 1000 Shades of Blue FLAC.flac
GetLink      :
GetFolder    :
IsLink       : False
IsFolder     : False
IsFileSystem : True
IsBrowsable  : False
ModifyDate   : 4/26/2014 8:41:08 PM
Size         : 34188974
Type         : FLAC File

For the first file it found the attribute 'bit-depth' and its index (174) but did not find the attribute for the second file. In neither case did the script actually find the correct bit depth but just left the value blank.

2
  • This is just far too broad & shows no research effort. Simplest way is set the appropriate headers as visible in iTunes… but as you have given us no clue as to what OS, for what purpose, no-one's going to come up with anything better.
    – Tetsujin
    Commented Aug 1, 2020 at 12:18
  • Thanks for the edit. I've retracted my downvote & also voted to reopen, but I'm afraid I know nothing of Windows, so can't help, sorry. Wish you luck.
    – Tetsujin
    Commented Aug 6, 2020 at 10:16

1 Answer 1

3

SoX (Sound Exchange), the self-described Swiss Army knife of sound processing programs is super-useful for these kind tasks.

soxi is the specific tool to list audio file information and on Linux (or MacOS) the command to recursively list all the information for all the audio files would be:

find . -name "*" -exec soxi {} 2> /dev/null \;

(the 2> /dev/null discards the errors for all unrecognised files).

Sample output:

Input File     : './Music/Chi Might III/MP3/10_BegginForFame48_CD.mp3'
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Duration       : 00:03:00.05 = 8642304 samples ~ 13503.6 CDDA sectors
File Size      : 7.20M
Bit Rate       : 320k
Sample Encoding: MPEG audio (layer I, II or III)


Input File     : './Music/Chi Might III/MP3/03_BalladOfAnEnglishMansSon48_CD.mp3'
Channels       : 2
Sample Rate    : 48000
Precision      : 16-bit
Duration       : 00:03:15.53 = 9385344 samples ~ 14664.6 CDDA sectors
File Size      : 7.82M
Bit Rate       : 320k
Sample Encoding: MPEG audio (layer I, II or III)

You can tailor the output for the information you need using either the command line options or grep.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.