Reading corrupted frames ffmpeg + x264 (Bug #1797)
Description
Ubuntu 10.0.4 LTS opencv build log, test.flv, and screen capture attached.
Checking video content:
--------------------------------------------------------------------------------
ffmpeg -i test.flv -sameq -ar 22050 output.mp4 #Stream #0:0 -> #0:0 (h264 -> mpeg4) #Stream #0:1 -> #0:1 (aac -> libmp3lame) ffmpeg -i test.flv -sameq -ar 22050 output.avi
Both input and output video is correctly encoded by ffmpeg.
However the opencv output frame is corrupted in reading files:
CvCapture *capture=cvCreateFileCapture("test.flv"); IplImage *img; if(cvGrabFrame(capture)) { imgBuffer = cvRetrieveFrame(capture); cvShowImage("image_src",imgBuffer); cvWaitKey(0); }
--------------------------------------------------------------------------------
Test 3:
--------------------------------------------------------------------------------
ffmpeg version N-39768-g62e5ef9 Copyright (c) 2000-2012 the FFmpeg developers built on Apr 13 2012 12:24:30 with gcc 4.4.3 configuration: --enable-shared --enable-static --enable-pic --enable-swscale --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libtheora --enable-libvorbis --enable-x11grab --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-bzlib --enable-libdc1394 --enable-libfaac --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxavs --enable-libxvid --enable-zlib --enable-openal --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-x11grab --enable-libdirac --enable-libnut --enable-avcodec --enable-avdevice --enable-libvo-aacenc --enable-libvo-amrwbenc libavutil 51. 46.100 / 51. 46.100 libavcodec 54. 14.101 / 54. 14.101 libavformat 54. 3.100 / 54. 3.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 69.101 / 2. 69.101 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 11.100 / 0. 11.100 libpostproc 52. 0.100 / 52. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
--------------------------------------------------------------------------------
OpenCV 2.4 outputs corrupted frame data:
[swscaler
0x2d12400] bad dst image pointers
[swscaler
0x652fcc0] bad dst image pointers--------------------------------------------------------------------------------
Test 2:
--------------------------------------------------------------------------------
ffmpeg version N-39757-gca19862 Copyright (c) 2000-2012 the FFmpeg developers built on Apr 12 2012 16:45:59 with gcc 4.4.3 configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libxvid --enable-x11grab --enable-swscale --enable-shared libavutil 51. 46.100 / 51. 46.100 libavcodec 54. 14.101 / 54. 14.101 libavformat 54. 3.100 / 54. 3.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 69.101 / 2. 69.101 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 11.100 / 0. 11.100 libpostproc 52. 0.100 / 52. 0.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
--------------------------------------------------------------------------------
OpenCV 2.4 outputs corrupted frame data:
[swscaler
0x1ac1400] bad dst image pointers
[swscaler
0x52decc0] bad dst image pointers--------------------------------------------------------------------------------
Test 1:
--------------------------------------------------------------------------------
ffmpeg version 0.8 (no longer builds with opencv 2.4)
--------------------------------------------------------------------------------
... snip ... [ 28%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg_v2.cpp.o In file included from /home/yourmom/SDK/opencv/trunk/opencv/modules/highgui/src/cap_ffmpeg_v2.cpp:46: /usr/local/include/libavformat/avformat.h: In member function ‘bool CvCapture_FFMPEG::reopen()’: /usr/local/include/libavformat/avformat.h:1217: error: too few arguments to function ‘int avformat_find_stream_info(AVFormatContext*, AVDictionary**)’ /home/yourmom/SDK/opencv/trunk/opencv/modules/highgui/src/cap_ffmpeg_impl_v2.hpp:349: error: at this point in file /usr/local/include/libavformat/avformat.h: In member function ‘bool CvCapture_FFMPEG::open(const char*)’: /usr/local/include/libavformat/avformat.h:1217: error: too few arguments to function ‘int avformat_find_stream_info(AVFormatContext*, AVDictionary**)’ /home/yourmom/SDK/opencv/trunk/opencv/modules/highgui/src/cap_ffmpeg_impl_v2.hpp:414: error: at this point in file make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg_v2.cpp.o] Error 1 make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2 make: *** [all] Error 2
Associated revisions
Merge pull request #1797 from moodoki:bugfix_3344
History
Updated by Joel Mckay almost 13 years ago
This appears to be related to compiling ffmpeg with "--enable-swscale"
Everything appears to work fine without error messages or image errors with this flag left out.
Seems rather odd...
Updated by Joel Mckay almost 13 years ago
Related to gcc, NVCC and ffmpeg repo build,
If opencv build shows broken deps with missing libavcodec.so.xx or linker gets jammed up it is likely multiple versions if ffmpeg libs are enabled via libutvideo
remove libunicap libucil packages (these depend on old orphon instance of new lib in /usr/lib):
apt-get remove libucil2-dev libunicap2-dev
Recompile opencv 2.4 with -DNEW_FFMPEG=1 and --enable-swscale will no longer corrupt frames
This issue was cause by the cuda compiler messing up which version of the library to link at around 52% to 58% build point in opencv.
An Ubuntu 10.04 LTS specific issue....
Annoying, but still better than the unity interface...
=)
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-video
Updated by Vadim Pisarevsky over 12 years ago
note for someone will look hopefully look at it during hackaton - need to check if the file is played fine on Ubuntu 12.04. If yes, the bug could be closed as obsolete (and in Ubuntu 12.04 one can install Gnome 3, MATE, KDE or Xfce, no need to use Unity :) )
- Target version deleted ()
- Assignee deleted (
Alexander Reshetnikov)
Updated by Kirill Kornyakov over 12 years ago
- Target version set to Next Hackathon
Updated by Andrey Pavlenko over 11 years ago
- Affected version set to 2.4.0 - 2.4.4
- Start date deleted (
2012-04-13) - Target version deleted (
Next Hackathon)
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4345