title: Reading video files with OpenCV VideoCapture
body: <p>I am having trouble being able top open any video files in OpenCV besides those encoded in MJPEG.</p>
  
  <p>I have installed OpenCV using <a href="https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/2.4/opencv2_4_2.sh" rel="nofollow">this</a> script (which should compile OpenCV with support for ffmpeg) and an testing using the sample provided <a href="http://docs.opencv.org/doc/tutorials/highgui/video-write/video-write.html" rel="nofollow">here</a>.</p>
  
  <p>When running with a h264 encoded video I get:</p>
  
  <pre><code>[mov,mp4,m4a,3gp,3g2,mj2 @ 0x123ed80] multiple edit list entries, a/v desync might occur, patch welcome
  [h264 @ 0x12465e0] A non-intra slice in an IDR NAL unit.
  [h264 @ 0x12465e0] decode_slice_header error
  Could not open the output video for write: test.mp4
  </code></pre>
  
  <p>When running with an MPEG-2 encoded video I get:</p>
  
  <pre><code>[mpegts @ 0x1e92d80] PES packet size mismatch
  [mpegts @ 0x1e92d80] PES packet size mismatch
  [mpegts @ 0x1e92d80] max_analyze_duration reached
  [mpegts @ 0x1e92d80] PES packet size mismatch
  Could not open the output video for write: test.mpeg
  </code></pre>
  
  <p>I am running x64 Ubuntu 12.04.</p>
  
  <p>EDIT: I tried OpenCV 2.4.8 on a Ubuntu 13.10 x86 VM, <code>ffmpeg</code> works fine, however the sample code still fails, this time with the following error:</p>
  
  <pre><code>[h264 @ 0x849ff40] A non-intra slice in an IDR NAL unit.
  [h264 @ 0x849ff40] decode_slice_header error
  Could not find encoder for codec id 28: Encoder not foundOpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend doesn't support this codec acutally.) in CvVideoWriter_GStreamer::open, file /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp, line 505
  terminate called after throwing an instance of 'cv::Exception'
    what():  /home/dan/Install-OpenCV/Ubuntu/2.4/OpenCV/opencv-2.4.8/modules/highgui/src/cap_gstreamer.cpp:505: error: (-210) Gstreamer Opencv backend doesn't support this codec acutally. in function CvVideoWriter_GStreamer::open
  </code></pre>