0

It is possible to convert all audio to mp3?

System.Diagnostics.Process proc = new System.Diagnostics.Process();
                    proc.EnableRaisingEvents = false;
                    proc.StartInfo.FileName = @"""C:\ffmpeg\bin\ffmpeg.exe""";
                    proc.StartInfo.Arguments = "-i C:\\Matheus\\Matheus_Project\\Matheus_Project\\App_Data\\" + User.Identity.Name + "\\" + fileNameAndType + " -acodec libmp3lame -ab 128k C:\\Matheus\\Matheus_Project\\Matheus_Project\\App_Data\\" + User.Identity.Name + "\\" + fileName + ".mp3";  /* use /y to overwrite if there it exists already or will fail */
                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.CreateNoWindow = false;
                    proc.StartInfo.RedirectStandardOutput = true;
                    proc.StartInfo.RedirectStandardError = true;
                    proc.Start();

                    var output = proc.StandardOutput.ReadToEnd();
                    string output_error = proc.StandardError.ReadToEnd();

                    proc.WaitForExit();
                    proc.Close();

Example:

  • audio/x-m4a to mp3

  • audio/mp4 to mp3

  • audio/basic to mp3

  • audio/L24 to mp3

  • audio/mid to mp3

  • audio/x-aiff to mp3

  • audio/x-mpegurl to mp3

  • audio/vnd.rn-realaudio to mp3

  • audio/ogg to mp3

  • audio/vorbis to mp3

  • audio/vnd.wav to mp3

Any idea ?

Matheus Miranda
  • 1,755
  • 2
  • 21
  • 36
  • But, your code works or not?...also, did your check this Q&A: http://stackoverflow.com/questions/3255674/convert-audio-files-to-mp3-using-ffmpeg – Hackerman Oct 28 '16 at 17:03

1 Answers1

0

public void ConvertWavToMp3(string filename) { try { string Flacfilename = AppDomain.CurrentDomain.BaseDirectory + "FlacRecording";

            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = false;
            psi.CreateNoWindow = true;
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.FileName = AppDomain.CurrentDomain.BaseDirectory + @"lame.exe";
            psi.Arguments = "-b" + "128" + " --resample " + "22.05" + " -m j " +
                           "\"" + filename + "\"" + " " +
                            "\"" + Flacfilename + "\\" + Path.GetFileNameWithoutExtension(filename) + ".mp3" + "\"";


            Process p = Process.Start(psi);
            p.WaitForExit();
            p.Close();
            p.Dispose();


        }
        catch (Exception ae)
        {
        }

    }

download lame.exe and put it in your application and call abover function with passing fullpath with wav file name.