title: Auto detect rotation and rotate video accordingly with mencoder, handbrake cli or ffmpeg
body: <p>I have found questions on rotating videos with mencoder and ffmpeg however I am after a fully automated solution. </p>
  
  <p>Can anybody help with this. </p>
  
  <p>I want to</p>
  
  <ul>
  <li>Detect the video orientation</li>
  <li>Rotate if needed</li>
  <li>Reset the meta data on the video (otherwise watching on a iOS device will cause unwanted rotation)</li>
  <li>Save video in desired format</li>
  </ul>
  
  <p>The reason for this is a wish to use the processed videos in a HTML5 video player. If I rotate without resetting the meta data iOS devices will read the meta and further rotate causing the video to be out by another 90 degrees.</p>