title: Is there a good way to tell if HandBrakeCLI actually encoded anything?
body: <p>I'm working on a system to convert a bunch of .mov files to H.264 (using HandBrakeCLI) and webm (using ffmpeg) as the .mov files are created.  In general, things are going very well.  I'm hung up on a bit of error detection.  I want to know if one of the encodings failed so that we can investigate, try again, etc.  </p>
  
  <p>To test encoding failure, I copied a text file into a file with a .mov extention, and set the programs about trying to encode it.  Naturally, they both fail to encode the file (I'm not sure what "success" would mean in this context...)  However, while ffmpeg reports this failure by setting its exit code to 1, HandBrakeCLI sets the exit code to 0, because it exited cleanly.  This is consistent with the <a href="https://trac.handbrake.fr/wiki/CLIGuide" rel="nofollow">HandBrakeCLI documentation</a>  but it leaves me wondering how I can tell if HandBrakeCLI knows if it failed to encode anything.  That same documentation page suggests "If you want to monitor HandBrake's process, you should monitor the standard pipes", so I'm now getting the effect that I want by doing something like this:  </p>
  
  <pre><code>HandBrakeCLI --preset 'Normal' --input bad.mov --output out.mv4 2&gt;&amp;1 | grep 'Encode done'
  </code></pre>
  
  <p>grep then sets its exit code to 0 if it found a match, and 1 if it didn't.  But, this seems rather barbaric: for instance, the text "Encode done!" could change in a future release of HandBrake.  </p>
  
  <p>So, anyone have a better way to tell if HandBrake encoded something or not?  </p>
  
  <p>Some edited shell output is included below for reference...</p>
  
  <pre><code>$ ffmpeg -i 'develqueuedir/B_BH_120409.mov' 'develqueuedir/B_BH_120409.webm'
  FFmpeg version 0.6.4-4:0.6.4-0ubuntu0.11.04.1, Copyright (c) 2000-2010 the Libav Developers
  [snip]
  develqueuedir/B_BH_120409.mov: Invalid data found when processing input
  
  $ echo $?
  1
  
  $ HandBrakeCLI --preset 'Normal' --maxWidth 720 --optimize --input 'develqueuedir/B_BH_120409.mov' --output 'develqueuedir/B_BH_120409.mv4'
  
  Output format couldn't be guessed from file name, using default.
  [11:45:45] hb_init: starting libhb thread
  HandBrake 0.9.6 (2012022900) - Linux x86_64 - http://handbrake.fr
  Opening develqueuedir/B_BH_120409.mov...
  [snip]
  [11:45:45] libhb: scan thread found 0 valid title(s)
  No title found.
  
  HandBrake has exited.
  
  $ echo $?
  0
  </code></pre>