OpenCV-C++ VideoCapture fails to open video files
<p>Recently I upgraded my OS from Ubuntu Precise Saucy (13.10) to Trusty (14.04).  After this upgrade, cv::VideoCapture became not working properly.  The program aborts when reading a video file.  For example,</p>

<pre><code>int main(int argc, char**argv)
{
  cv::VideoCapture vin("sample/vout2l.avi");
...
</code></pre>

<p>Executing this program, it aborts with a message:</p>

<pre><code>*** Error in `./cv2-videoread.out': malloc(): memory corruption: 0x0000000000e3eff0 ***
Abort (core dumped)
</code></pre>

<p>The backtrace looks like:</p>

<pre><code>[New LWP 15586]
[New LWP 15587]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./cv2-videoread.out'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007ff953e61c37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ff953e61c37 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ff953e65028 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ff953e9e2a4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007ff953eabe26 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ff953eac1ab in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00007ff953eadba4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x00007ff953eaf7d2 in posix_memalign () from /lib/x86_64-linux-gnu/libc.so.6
#7  0x00007ff94fa640fe in av_malloc () from /usr/lib/x86_64-linux-gnu/libavutil.so.52
#8  0x00007ff94fa641b1 in av_strdup () from /usr/lib/x86_64-linux-gnu/libavutil.so.52
#9  0x00007ff94fa5e5db in av_dict_set ()
  from /usr/lib/x86_64-linux-gnu/libavutil.so.52
#10 0x00007ff954738574 in CvCapture_FFMPEG::open(char const*) ()
  from /usr/lib/libopencv_highgui.so.2.4
#11 0x00007ff954738719 in cvCreateFileCapture_FFMPEG ()
  from /usr/lib/libopencv_highgui.so.2.4
#12 0x00007ff95473aac9 in cvCreateFileCapture_FFMPEG_proxy(char const*) ()
  from /usr/lib/libopencv_highgui.so.2.4
---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
#13 0x00007ff954722d89 in cvCreateFileCapture ()
  from /usr/lib/libopencv_highgui.so.2.4
#14 0x00007ff954723045 in cv::VideoCapture::open(std::string const&amp;) ()
  from /usr/lib/libopencv_highgui.so.2.4
#15 0x00007ff95472315c in cv::VideoCapture::VideoCapture(std::string const&amp;) ()
  from /usr/lib/libopencv_highgui.so.2.4
#16 0x0000000000401281 in main (argc=1, argv=0x7fff1f938388) at cv2-videoread.cpp:30
(gdb)
</code></pre>

<p>NOTE: <code>cv::VideoCapture vin(...</code> is 30th line.</p>

<p>Before upgrading the OS, this code was working with the same input file.</p>

<p>From the backtrace, it seems that the trouble happens at <code>CvCapture_FFMPEG</code> and <code>libavutil</code>.  I upgraded the packages <code>ffmpeg libavutil-dev libavutil51 libavutil52</code> but they were already up-to-date.
Also, OpenCV packages are up-to-date (I checked <code>libopencv-core-dev libopencv-core2.4 libopencv-dev libopencv-highgui-dev libopencv-highgui2.4</code>).</p>

<p>I also tested OpenCV built from source, but got the same results.</p>

<p>Do you have ideas to figure this out?</p>