1

I am trying to convert an MP3 file to GSM encoded WAV using SoX

The C# code to execute this is:

Console.WriteLine(Cfg.SoxPath); // bin/sox.exe
Console.WriteLine(args); // A rather long argument
var startInfo = new ProcessStartInfo();
startInfo.FileName = Cfg.SoxPath;
startInfo.Arguments = args;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = false;

using (Process soxProc = Process.Start(startInfo))
{
    soxProc.WaitForExit();
}

The output of the code is:

bin\sox.exe  
"D:\VoiceRecorder Soundfiles Storage\MP3 Storage\2012-12-05\227\1\20121205_203436_2103c60a0000134850bfa1bd2c99_8075598.mp3" -c 1 -r 8000 -e gsm-full-rate "temp\227_20120901\SW120006_349990195665213_040154700_20121205203436_20.wav"  
bin\sox.exe FAIL formats: can't open input file `8000': No such file or directory

What causes the command to fail?

Things to consider

  • The command runs perfectly when executed directly from cmd prompt
  • Arguments (-c 1 -r 8000 -e gsm-full-rate) are fetched from an sql server
  • Minor changes to argument (e.g. replacing -e with --encoding) may change error message
  • Tried .NET 3.0 and 4.0
  • Error message has even included characters not part of arguments (can't open input file 'ûg')
  • The same arguments always results in the same error
ANisus
  • 74,460
  • 29
  • 162
  • 158

1 Answers1

1

I changed the arguments "in between" to:

-r 8k -e gsm-full-rate -c 1

It started working even though it is the same arguments, just shuffled around a little.
I still have no clue why it wouldn't work from .NET but only from command line prior to these edits.

But now it works.

ANisus
  • 74,460
  • 29
  • 162
  • 158