VideoWriter FFmpeg libs incompatible with VS 2008 (Bug #308)
Description
(Visual Studio 2008 SP1, Win XP 32 Bit)
When execute the following Code:
//int x = CV_FOURCC('M','J','P','G');
int x = CV_FOURCC('X','V','I','D');
Mat im = imread("C:\\test2.jpg"); //640x480
VideoWriter *vw = new [[VideoWriter]]();
vw->open("test.avi",x,25.0,im.size());
bool b = vw->isOpened();
for(int i=0;i<100;i++)
{
(*vw)<<im;
}
delete vw;
I get an access violation reading location 0xffffffff in
cvWriteFrame (opencv_ffmpeg210d.dll) and the console says:
"Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec,but in the compiler. You may try recompiling using gcc >= 4.2.Do not report crashes to FFmpeg developers."
My solution is to recompile the static ffmpeg libraries:
1. Get the latest ffmpeg from SVN.
2. Compile ffmpeg with mingw
configure --enable-memalign-hack
(See: http://ffmpeg.arrozcru.org/wiki/index.php?title=Static)
3. Recompile opencv with the new ffmpeg libs(VS 2008) - and it
should work.
History
Updated by Marcus Wirsing almost 15 years ago
My gcc Version is 4.4.0
Updated by michaelp - almost 15 years ago
Can you upload your ffmpeg build? I can't get mine to run with opencv (unresolved external symbol _img_convert).
Updated by Marcus Wirsing almost 15 years ago
Replying to [comment:2 michaelp]:
Can you upload your ffmpeg build? I can't get mine to run with opencv (unresolved external symbol _img_convert).
You must define HAVE_FFMPEG_SWSCALE in opencv_ffmpeg, and replace the old ffmpeg headers with the new. You must also replace the mingw specific libs and include
the libswscale.a.
See:
http://rapidshare.com/files/384609847/patch.zip.html
(OpenCV Rev: 3045,
FFmpeg Rev:23053 [configure --enable-memalign-hack --disable-debug])
Updated by michaelp - almost 15 years ago
Replying to [comment:3 heso]:
You must define HAVE_FFMPEG_SWSCALE in opencv_ffmpeg, and replace the old ffmpeg headers with the new. You must also replace the mingw specific libs and include
the libswscale.a.See:
http://rapidshare.com/files/384609847/patch.zip.html
(OpenCV Rev: 3045,
FFmpeg Rev:23053 [configure --enable-memalign-hack --disable-debug])
Thanks, I managed to compile by sticking with 0.5 which does not require any modification except for the proper configure command.
Updated by anonymous - over 14 years ago
For this problem:
"Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec,but in the compiler. You may try recompiling using gcc >= 4.2.Do not report crashes to FFmpeg developers."
My solution is replace binaries of .\3rdparty\lib\:
-libavcodec.a, libavdevice.a,libavformat.a,libavutil.a
with previous version found in OpenCv2.0
Now coding it works.
Rudy
Updated by Andrey Morozov over 13 years ago
working in the latest version
- Status changed from Open to Done
- (deleted custom field) set to obsolete
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-video