title: .net application returns a connection reset when converting non-wav or non-mp3 files using FFmpeg
body: <p>I am currently making a .NET application which allows the user to upload an audio file and convert it into an mp3. I am using FFmpeg. It works with .wav and .mp3, but the application returns a "connection was reset" (I use Firefox 4 for testing) when I try to upload formats like .wma or .m4a. Naturally, when I was testing for errors by uploading unsupported files like .jpg it also returned the same thing. The command line argument worked as intended when I did it using cmd.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using System.Diagnostics;
  using System.Media;
  using System.ComponentModel;
  using System.ComponentModel.Design;
  using System.Text.RegularExpressions;
  
  namespace AudioConvert
  {
      public partial class _Default : System.Web.UI.Page
      {
          Process ffmpeg;
          protected void Page_Load(object sender, EventArgs e)
          {
  
          }
  
          protected void btnUpload_Click(object sender, EventArgs e)
          {
              string audio;
              string mp3;
  
              if (FileUpload1.HasFile)
              {
                  FileUpload1.SaveAs(@"\Temp\"+FileUpload1.FileName);
              }
  
              //FileUpload1.SaveAs(Server.MapPath("") + System.IO.Path.GetFileName(FileUpload1.FileName));
              audio = @"\Temp\"+FileUpload1.FileName; //audio filepath
              mp3 = Page.MapPath("") + "\\Media\\"+FileUpload1.FileName+".mp3";
              ffmpeg = new Process();
  
              try
              {
  
                  ffmpeg.StartInfo.Arguments = "-y -i \"" + audio + "\" -ab 128k \"" + mp3; //-command line argument, overwrites automatically
                  ffmpeg.StartInfo.FileName = Page.MapPath("ffmpeg.exe"); //ffmpeg file location
                  ffmpeg.Start();
                  ffmpeg.WaitForExit();
                  ffmpeg.Close();
              }
              catch
              {
              }
          }
      }
  }
  </code></pre>