Script to find and convert stereo WAV's that are actually mono?

1

Hi I have a bunch of recordings in my library that are stereo WAV's but are actually mono. Is there a script or program for mac that would find and convert the WAV's to mono ?

user16701

Posted 2016-02-06T18:25:45.707

Reputation: 21

1Converting is trivial. Finding, not quite. Are they really mono files stored in stereo format, or just stereo files with very little stereo width? – leftaroundabout – 2016-02-06T21:57:58.457

Yes they are 100% the same signal on both channels. – user16701 – 2016-02-07T14:36:57.620

Answers

2

A procedure that would definitely work: for each file ${f}.wav,

  • Split it up to M/S stereo, i.e. to a file ${f}_M.wav and a file ${f}_S.wav. For instance with

    ffmpeg -i ${f}.wav -filter_complex "[0:0]pan=1c|c0=0.5 * c0 + 0.5 * c1[mid];[0:0]pan=1c|c0 = 0.5 * c0 + -0.5 * c1[side]" -map "[mid]" ${f}_M.wav -map "[side]" ${f}_S.wav
    
  • If f.wav is actually mono, then f_S.wav will contain silence. You can detect this by analysing the volume. This is also possible with ffmpeg

    ffmpeg -i ${f}_S.wav -af "volumedetect" -f null /dev/null
    

    but it's a bit awkward to parse the output; there's probably an easier tool for this.

    • If it is mono, overwrite f.wav with the equivalent mono file f_M.wav.
    • Else delete f_M.wav.
  • Either way, delete f_S.wav.

leftaroundabout

Posted 2016-02-06T18:25:45.707

Reputation: 5 941