title: OpenCV VideoWriter will not open
body: <p>I'm having trouble instantiating and opening an OpenCV <code>VideoWriter</code> for recording video on a Raspberry Pi (Raspbian Weezy).</p>
  
  <p>My project is written in C++, but I've written a minimal Python program that demonstrates the problem.</p>
  
  <p><a href="https://gist.github.com/chriscollins/11ff2f43852e1c93dae8">https://gist.github.com/chriscollins/11ff2f43852e1c93dae8</a></p>
  
  <p>Both my C++ code and the Python code above run without problem on my Windows machine.  Sometimes the writer does not open, but that's to be expected - I don't have all of the listed codecs installed (the list of codecs comes from the Open CV source), but a good number of them work correctly.  However, on a Raspberry Pi, both the C++ code and the Python code fail with the <code>VideoWriter</code> never being opened.  In the above Python code, <code>writer.isOpened()</code> returns false for every single codec, when run on a Raspberry Pi.</p>
  
  <p>I've <code>chown</code>ed the destination directory to the user I'm running the Python script as, and <code>chmod</code>ded it to <code>777</code> so I don't believe that it is a permissions problem.  I think it may be connected with how I've installed OpenCV or some of its dependencies, but I'm not sure how to rectify it.</p>
  
  <p>The install process I've used is as follows:</p>
  
  <ol>
  <li><p>Update firmware/packages via <code>rpi-update</code>, <code>apt-get update</code> and <code>apt-get upgrade</code>.</p></li>
  <li><p>Install the following dependencies via <code>apt-get</code>:
  <code>
  libjpeg8
  libjpeg8-dev
  libjpeg8-dbg
  libjpeg-progs
  ffmpeg
  libavcodec-dev
  libavcodec53
  libavformat53
  libavformat-dev
  libgstreamer0.10-0-dbg
  libgstreamer0.10-0
  libgstreamer0.10-dev
  libxine1-ffmpeg
  libxine-dev
  libxine1-bin
  libunicap2
  libunicap2-dev
  swig
  libv4l-0
  libv4l-dev
  python-numpy
  libpython2.6
  python-dev
  python2.6-dev
  libgtk2.0-dev
  </code></p></li>
  <li><p>Download and unzip <a href="http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip">http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip</a> to <code>/root/opencv-2.4.9</code>.</p></li>
  <li><p><code>cd /root/opencv-2.4.9</code> and run <code>cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_opencv_ocl=OFF</code>.  Output of cmake is available at <a href="https://gist.github.com/chriscollins/d8060e03a6acd6d4336c">https://gist.github.com/chriscollins/d8060e03a6acd6d4336c</a></p></li>
  <li><p><code>make</code> and <code>make install</code> from the same directory.</p></li>
  </ol>
  
  <p>Various other OpenCV functionality works correctly on the Raspberry Pi (in C++ or in Python) - e.g. viewing a webcam via <code>VideoCapture</code>, but I can't get the <code>VideoWriter</code> to work.  I'm tempted to try installing FFMPEG from source instead of via <code>apt-get</code>, but as <code>make</code> takes 5+ hours to run on a Raspberry Pi, I was hoping I'd find the answer here, rather than proceeding with a trial and error approach!</p>
  
  <p>Any advice on how to solve (or debug) this is appreciated.</p>
  
  <p>EDIT: Added output of cmake command (<a href="https://gist.github.com/chriscollins/d8060e03a6acd6d4336c">https://gist.github.com/chriscollins/d8060e03a6acd6d4336c</a>)</p>