title: How to queue ffmpeg FIFO
body: <p>we build a service similar to youtube. Also converting runs fine with ffmpeg using this script from another post here:</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/12698006/how-do-i-set-up-an-ffmpeg-queue">How do I set up an ffmpeg queue?</a></p>
  </blockquote>
  
  <pre><code>#!/bin/bash
  
  pipe=/tmp/ffmpeg
  
  trap "rm -f $pipe" EXIT
  
  # creating the FIFO    
  [[ -p $pipe ]] || mkfifo $pipe
  
  while true; do
  # can't just use "while read line" if we 
  # want this script to continue running.
  read line &lt; $pipe
  
  # now implementing a bit of security,
  # feel free to improve it.
  # we ensure that the command is a ffmpeg one.
  [[ $line =~ ^ffmpeg ]] &amp;&amp; bash &lt;&lt;&lt; "$line"
  done
  </code></pre>
  
  <p>This works pretty good when i send one by one to the named pipe. When i send more than one at same time the second one queues the terminal to the point the first one finished. if a try more than 2 the third one will not be transcoded.</p>
  
  <p>So i tried to workaround with background sending to get the terminal free (just drop the echo command and close the ssh connection) but this doesn't work, then i played around with screen -X but also no luck. Maybe someone has a good idea to deal this.</p>
  
  <p>What i wanna do is: Every uploaded video which is needed to transcode will send a echo to the named pipe. FIFO should match but not blocking the terminal. So i think i need something to really queue ffmpeg input.</p>
  
  <p>kindest regards
  Francois</p>