title: Zenity --progress from Handbrake CLI output
body: <p>My goal is to create a gtk progress bar with the output of HandBrakeCLI using zenity --progress.  I've ran into some snags and I'm wondering if someone knows of a better way or can help me with what I'm currently doing.</p>
  
  <p>Normal Output:</p>
  
  <pre><code>HandBrakeCLI -i infile -o outfile --preset=iPad
  </code></pre>
  
  <p>Displays </p>
  
  <blockquote>
    <p>Encoding: task 1 of 1, 11.97 % (72.81 fps, avg 86.78 fps, ETA 00h00m43s)</p>
  </blockquote>
  
  <p>HandBrake piped to tr and cut commands so I only have the percentages that zenity will expect.</p>
  
  <pre><code>HandBrakeCLI -i infile -o outfile --preset=iPad 2&gt;&amp;1 | tr -s '\r' '\n' | cut -b 24-28
  </code></pre>
  
  <p>Results in what I would expect:</p>
  
  <pre><code>1.05 
  1.06 
  1.10 
  1.10
  </code></pre>
  
  <p>But, the output is delayed a lot and sometimes won't even display.  If I only use my tr expression I get the output above on each line but it's the whole output including "Encoding: task......".</p>
  
  <p>It's like the cut command can't keep up with the std out of Handbrake.  I read up on using named pipes, created one and directed HandBrake's output to the pipe then in another terminal tried the tr and cut command via the pipe and it results in the same delay.</p>
  
  <p>Using awk's print substring also results in the same delay.</p>
  
  <p>I can't figure it out.  I'm after the zenity --progress indicator because my HandBrake job is called as a MythTV job and I'd like a progress bar to pop up so I know when and an encode is in process.</p>