title: ffmpeg.exe freezes
body: <p>I'm using Asp.Net C# Framework 4 and currently developing a video conversion application. I'm also using ffmpeg to convert from all uploaded formats to flv. I'm first converting uploaded file to mpg and after to flv due to problems I encountered while trying conversion directly to flv from mp4 sometimes. But ffmpeg freezes as soon as it's done with conversion process to mpg file. When I run task manager and check the processes list, it just stands there using no CPU resource. When I end the ffmpeg process directly from task manager, other process take place which converts from mpg to flv and preview file (jpg) and works smoothly. Due to freezing of first process, the second process cannot start when I try to upload from my web page's file upload form. I appreciate any response from now. Here is my code: </p>
  
  <pre><code>        string duration = "00:00:00";
  
          //converting video
          Process ffmpeg;
          ffmpeg = new Process();
  
          // convert to mpg 1st
          ffmpeg.StartInfo.Arguments = " -i \"" + Server.MapPath("static/user/vid/") + videolink + "\" -f mpeg -b 300k -ac 2 -ab 128k -ar 44K \"" + Server.MapPath("static/user/vid/") + mpglink + "\"";
          ffmpeg.StartInfo.FileName = Page.MapPath("bin/ffmpeg.exe");
          ffmpeg.StartInfo.CreateNoWindow = true;
          ffmpeg.StartInfo.UseShellExecute = false;
          ffmpeg.StartInfo.RedirectStandardOutput = true;
          ffmpeg.StartInfo.RedirectStandardError = true;
          ffmpeg.Start();
  
          ffmpeg.WaitForExit();
          ffmpeg.Close();
  
  
          // mpg 2 flv
          ffmpeg = new Process();
          ffmpeg.StartInfo.Arguments = " -i \"" + Server.MapPath("static/user/vid/") + mpglink + "\" -f flv -s 624x352 \"" + Server.MapPath("static/user/vid/") + flvlink + "\"";
          ffmpeg.StartInfo.FileName = Page.MapPath("bin/ffmpeg.exe");
          ffmpeg.StartInfo.CreateNoWindow = true;
          ffmpeg.StartInfo.UseShellExecute = false;
          ffmpeg.StartInfo.RedirectStandardOutput = true;
          ffmpeg.StartInfo.RedirectStandardError = true;
          ffmpeg.Start();
  
          ffmpeg.BeginOutputReadLine();
          string error = ffmpeg.StandardError.ReadToEnd();
          ffmpeg.WaitForExit();
  
          try
          {
              duration = error.Substring(error.IndexOf("Duration: ") + 10, 8);
          }
          catch
          {
          }
  
          if (ffmpeg.ExitCode != 0)
          {
              ltrUpload.Text = "&lt;div class=\"resultbox-negative\" id=\"divResult\"&gt;Problem occured during upload process. Error code: " + error + "&lt;br&gt;" + "&lt;/div&gt;";
              return;
          }
          ffmpeg.Close();
  
  
          // generate preview image
          ffmpeg.StartInfo.Arguments = " -i \"" + Server.MapPath("static/user/vid/") + flvlink + "\" -s 624x352 -ss 00:00:03 -an -vframes 1 -f image2 -vcodec mjpeg \"" + Server.MapPath("static/user/vid/") + flvlink.Replace(".flv", ".jpg") + "\"";
          ffmpeg.StartInfo.FileName = Page.MapPath("bin/ffmpeg.exe");
          ffmpeg.StartInfo.CreateNoWindow = true;
          ffmpeg.StartInfo.UseShellExecute = false;
          ffmpeg.StartInfo.RedirectStandardOutput = true;
          ffmpeg.StartInfo.RedirectStandardError = true;
          ffmpeg.Start();
          ffmpeg.WaitForExit();
          ffmpeg.Close();
  
          // deleting original file and mpg
          FileInfo fi = new FileInfo(Server.MapPath("static/user/vid/") + videolink);
          if (fi.Exists) fi.Delete();
          fi = new FileInfo(Server.MapPath("static/user/vid/") + mpglink);
          if (fi.Exists) fi.Delete();
  </code></pre>