title: Create conversion queue using ffmpeg and C #
body: <p>Ok, the idea is to create a file queue that can be modified and reorganized (this is done) and for each file execute a ffmpeg process to convert it to another format.</p>
  
  <p>For conversion use Xabe.FFmpeg and .Net 4.5 all using async and await.</p>
  
  <p>The question would be how to execute an x ​​number of processes in parallel (example 4) of that variable queue and when one of them finishes executing the next one, keeping in execution always the same amount in parallel. I can start from scratch but I need ideas on how to do this in the simplest way possible. The program itself is simple (with gui) takes a folder and its subfolders all the video files and queues them and starts the conversion, you can add other folders with more files, and independent files reorder them, to convert whichever is the greater.</p>
  
  <p>At one point I found a package I think nuget (or github) that did exactly what I needed but I have not been able to get back.</p>
  
  <p>Thanks for your help in advance.</p>
  
  <p>Excuse the English because I use the translator of Google for being faster because my domain of this is limited but sufficient to understand the answers.</p>
  
  <hr>
  
  <p>Ok, I found what I was looking for called ProcessManager is a nupkg package. It has 2 years of development but seems stable. The only drawback is that it does not allow me to organize the conversion queue once you have added the files, although I have to try some ideas that maybe functions.</p>
  
  <pre><code>var manager = new Manager(4); // Max 4 processes will be started simultaneously
  manager.Start();
  
  manager.ProcessErrorDataReceived += (sender, e) =&gt; Console.WriteLine(e.Data);
  manager.ProcessOutputDataReceived += (sender, e) =&gt; Console.WriteLine(e.Data);
  
  foreach (var videoFileName in Directory.EnumerateFiles("videos"))
  {
      var info = new ProcessInfo(
          "ffprobe.exe",
          string.Format("-v quiet -print_format json -show_format -show_streams \"{0}\"", videoFileName));
  
      manager.Queue(info);
  }
  </code></pre>
  
  <p><a href="https://github.com/huysentruitw/process-manager" rel="nofollow noreferrer">Process Manager</a></p>