Hi,

OpenCV video stuff wasn't working, this was because it wasn't compiling against ffmpeg anymore. I don't know for sure where to report this, but I think this is the right place.

I made a patch to fix this, see attachment. I'm not a very good C hacker so there may be some problems, but for me it is working (and I had more positive reports).

The patch is based upon the gentoo fix:
* http://bugs.gentoo.org/attachment.cgi?id=130219&action=edit

The complete packages can also be downloaded from the launchpad PPA that I created for this:
* https://launchpad.net/~gijzelaar/+archive/opencv

I hope this is useful.

- gijs

diff -uNr opencv-1.0.0/configure opencv-1.0.0-fixed/configure
--- opencv-1.0.0/configure	2009-05-03 17:11:43.192450271 +0200
+++ opencv-1.0.0-fixed/configure	2009-05-03 17:15:02.471951090 +0200
@@ -22467,8 +22467,8 @@
     fi
     if test x"$with_ffmpeg" = "xyes"; then
         if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
-  { echo "$as_me:$LINENO: checking for ffmpeg/avcodec.h" >&5
-echo $ECHO_N "checking for ffmpeg/avcodec.h... $ECHO_C" >&6; }
+  { echo "$as_me:$LINENO: checking for libavcodec/avcodec.h" >&5
+echo $ECHO_N "checking for libavcodec/avcodec.h... $ECHO_C" >&6; }
 if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
@@ -22476,8 +22476,8 @@
 echo "${ECHO_T}$ac_cv_header_ffmpeg_avcodec_h" >&6; }
 else
   # Is the header compilable?
-{ echo "$as_me:$LINENO: checking ffmpeg/avcodec.h usability" >&5
-echo $ECHO_N "checking ffmpeg/avcodec.h usability... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking libavcodec/avcodec.h usability" >&5
+echo $ECHO_N "checking libavcodec/avcodec.h usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -22485,7 +22485,7 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 $ac_includes_default
-#include <ffmpeg/avcodec.h>
+#include <libavcodec/avcodec.h>
 _ACEOF
 rm -f conftest.$ac_objext
 if { (ac_try="$ac_compile"
@@ -22517,15 +22517,15 @@
 echo "${ECHO_T}$ac_header_compiler" >&6; }
 
 # Is the header present?
-{ echo "$as_me:$LINENO: checking ffmpeg/avcodec.h presence" >&5
-echo $ECHO_N "checking ffmpeg/avcodec.h presence... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking libavcodec/avcodec.h presence" >&5
+echo $ECHO_N "checking libavcodec/avcodec.h presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <ffmpeg/avcodec.h>
+#include <libavcodec/avcodec.h>
 _ACEOF
 if { (ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
@@ -22558,25 +22558,25 @@
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
   yes:no: )
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: proceeding with the compiler's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: proceeding with the compiler's result" >&2;}
     ac_header_preproc=yes
     ;;
   no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: ffmpeg/avcodec.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: ffmpeg/avcodec.h: in the future, the compiler will take precedence" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: libavcodec/avcodec.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: libavcodec/avcodec.h: in the future, the compiler will take precedence" >&2;}
     ( cat <<\_ASBOX
 ## -------------------------------------------------------- ##
 ## Report this to opencvlibrary-de...@lists.sourceforge.net ##
@@ -22585,8 +22585,8 @@
      ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
-{ echo "$as_me:$LINENO: checking for ffmpeg/avcodec.h" >&5
-echo $ECHO_N "checking for ffmpeg/avcodec.h... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: checking for libavcodec/avcodec.h" >&5
+echo $ECHO_N "checking for libavcodec/avcodec.h... $ECHO_C" >&6; }
 if test "${ac_cv_header_ffmpeg_avcodec_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
diff -uNr opencv-1.0.0/configure.in opencv-1.0.0-fixed/configure.in
--- opencv-1.0.0/configure.in	2009-05-03 17:11:43.107950357 +0200
+++ opencv-1.0.0-fixed/configure.in	2009-05-03 17:15:02.471951090 +0200
@@ -441,7 +441,7 @@
        with_ffmpeg=yes
     fi
     if test x"$with_ffmpeg" = "xyes"; then
-        AC_CHECK_HEADER(ffmpeg/avcodec.h,
+        AC_CHECK_HEADER(libavcodec/avcodec.h,
                                                     [
                                                       have_ffmpeg=yes
                                                       AC_DEFINE(HAVE_FFMPEG,,[FFMpeg video library])
diff -uNr opencv-1.0.0/otherlibs/highgui/cvcap_ffmpeg.cpp opencv-1.0.0-fixed/otherlibs/highgui/cvcap_ffmpeg.cpp
--- opencv-1.0.0/otherlibs/highgui/cvcap_ffmpeg.cpp	2009-05-03 17:11:43.264451368 +0200
+++ opencv-1.0.0-fixed/otherlibs/highgui/cvcap_ffmpeg.cpp	2009-05-03 17:15:24.011950348 +0200
@@ -41,9 +41,14 @@
 
 #include "_highgui.h"
 
+#define __STDC_CONSTANT_MACROS
 
 extern "C" {
-#include <ffmpeg/avformat.h>
+#include <libavformat/avformat.h>
+#include <libavcodec/avcodec.h>
+#include <libswscale/swscale.h>
+#include <sys/types.h> /* size_t */
+#include <sys/errno.h>
 }
 
 #ifdef NDEBUG
@@ -52,6 +57,8 @@
 #define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
 #endif
 
+static struct SwsContext *img_convert_ctx;
+
 typedef struct CvCaptureAVI_FFMPEG
 {
     CvCaptureVTable   * vtable;
@@ -214,19 +221,21 @@
 {
     if( !capture || !capture->video_st || !capture->picture->data[0] )
     return 0;
-#if LIBAVFORMAT_BUILD > 4628
-    img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
-                 (AVPicture*)capture->picture,
-                 capture->video_st->codec->pix_fmt,
-                 capture->video_st->codec->width,
-                 capture->video_st->codec->height );
-#else
-    img_convert( (AVPicture*)&capture->rgb_picture, PIX_FMT_BGR24,
-                 (AVPicture*)capture->picture,
-                 capture->video_st->codec.pix_fmt,
-                 capture->video_st->codec.width,
-                 capture->video_st->codec.height );
-#endif
+
+    img_convert_ctx = sws_getContext(capture->video_st->codec->width,
+				     capture->video_st->codec->height,
+				     capture->video_st->codec->pix_fmt,
+				     capture->video_st->codec->width,
+				     capture->video_st->codec->height,
+				     PIX_FMT_BGR24,
+				     SWS_BICUBIC,
+				     NULL, NULL, NULL);
+    
+    sws_scale(img_convert_ctx, capture->picture->data, 
+	      capture->picture->linesize, 0,
+	      capture->video_st->codec->height, 
+	      capture->rgb_picture.data, capture->rgb_picture.linesize);
+    
     return &capture->frame;
 }
 
@@ -713,9 +722,20 @@
 				PIX_FMT_BGR24, image->width, image->height);
 
 		// convert to the color format needed by the codec
-		if( img_convert((AVPicture *)mywriter->picture, c->pix_fmt,
-					(AVPicture *)mywriter->rgb_picture, PIX_FMT_BGR24, 
-					image->width, image->height) < 0){
+		img_convert_ctx = sws_getContext(image->width,
+						 image->height,
+						 PIX_FMT_BGR24,
+						 c->width,
+						 c->height,
+						 c->pix_fmt,
+						 SWS_BICUBIC,
+						 NULL, NULL, NULL);
+		
+		if ( sws_scale(img_convert_ctx, mywriter->rgb_picture->data, 
+			       mywriter->rgb_picture->linesize, 0,
+			       image->height, 
+			       mywriter->picture->data, mywriter->picture->linesize) < 0 )
+		{
 			CV_ERROR(CV_StsUnsupportedFormat, "FFMPEG::img_convert pixel format conversion from BGR24 not handled");
 		}
 	}
diff -uNr opencv-1.0.0/configure.in opencv-1.0.0-fixed/configure.in
--- opencv-1.0.0/configure.in	2009-05-03 20:10:05.383950421 +0200
+++ opencv-1.0.0-fixed/configure.in	2009-05-03 20:11:09.832018063 +0200
@@ -446,6 +446,7 @@
                                                       have_ffmpeg=yes
                                                       AC_DEFINE(HAVE_FFMPEG,,[FFMpeg video library])
                                                       FFMPEGLIBS="`pkg-config --libs libavcodec libavformat libavutil libswscale`"
+                                                      LIBS="$LIBS $FFMPEGLIBS"
                                                     ],
                         [ have_ffmpeg=no ])
     else
diff -uNr opencv-1.0.0/configure opencv-1.0.0-fixed/configure
--- opencv-1.0.0/configure	2009-05-03 20:16:55.992951051 +0200
+++ opencv-1.0.0-fixed/configure	2009-05-03 20:24:43.551950430 +0200
@@ -22604,7 +22604,8 @@
 #define HAVE_FFMPEG
 _ACEOF
 
-                                                      FFMPEGLIBS="`pkg-config --libs libavcodec libavformat`"
+                                                      FFMPEGLIBS="`pkg-config --libs libavcodec libavformat libavutil libswscale`"
+                                                      LIBS="$LIBS $FFMPEGLIBS"
 
 else
    have_ffmpeg=no
-- 
Ubuntu-motu mailing list
Ubuntu-motu@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-motu

Reply via email to