Pages

Thursday, February 28, 2019

The Dumb is Getting Worse

I need to see which mp3 files are VBR.  (The Jaguar cannot process VBR MP3s.)  First I tried to do a foreach loop in Windows cmd:
foreach %i in *.mp3
echo %i
MediaInfo %i } grep "Bit rate mode"
endfor
No luck.  This matches what I can find on line.  So I ran bash in cygwin:
for i in (ls *.mp3)
do
echo $i
MediaInfo.exe $1 |grep "Bit rate mode"
done
"i was unexpected at this time."  I was at least expecting the file names, from the echo command.

MediaInfo works fine, file by file or with *.mp3.  At least in CLI mode.  I could not figure out how to display the needed data in GUI mode.

Found an easier way that does not require my apparently lost scripting skill:
MediaInfo.exe *.mp3 |grep "Bit rate mode\|Complete name"
This gives file name and bit rate mode on subsequent lines.

I then used Lame to do the VBR to CBR conversion, and it produces only static.  So now I am restoring from my backup and I will just use MediaInfo to find which are VBR and do the conversion with Audacity.  Very slow but it works.

The bash script for identifying VBR files:
for file in $(ls *.mp3 */*.mp3); do count=`C:/MediaInfo.exe $file | grep "Bit rate mode" | grep "Variable" | wc -l`; if [ $count -gt 0 ]; then echo $file VBR; fi done
There is probably a more elegant solution using find, but I have other things to do.  Problem : $ls produces a series of words separated by blanks because many of the directory names have blanks.  How do I force it not to do that?  IFS=$'\n'

3 comments:

  1. for %x in (*.mp3) do MediaInfo %x | findstr /c:"Bit rate mode"

    ReplyDelete
  2. I'm 20 years out of the loop on sound conversion utilities, but it seems that one could do a blanket conversion of all audio files in a folder from whatever a file is to a new version in a new folder that is designated to be a non-variable bit-rate MP3.

    There's some inevitable quality loss with any reconversion of an MP3, but that may not really be noticeable in car listening.

    ReplyDelete
  3. Rod: Thanks. I just produced a list of all my MP3 files and then used emacs to generate all the calls to LAME to force them to CBR.

    ReplyDelete