retitle 586550 ffmpeg-php: FTBFS with ffmpeg >= 0.6
tags 586550 +patch
thanks

ffmpeg 0.7 is now in unstable and ffmpeg-php FTBFS in unstable with the 
following error.

checking whether to force gd support in ffmpeg-php... yes
configure: error: ffmpeg shared libraries not found. Make sure ffmpeg is 
compiled as shared libraries using the --enable-shared option
checking for ffmpeg headers... ...found in /usr/include/libavcodec
checking for ffmpeg libavcodec.so... make: *** [build-stamp] Error 1


When trying to get the package buildable again I ended up with a number of fixes
* two patches from ubuntu for ffmpeg and libav changes
* a patch to config.m4 to make the package find libavcodec.so * a patch to fix the expected result of a the ID3 test
* a change to debian/rules to make it run the tests noninteractively
 (for some reason even after I fixed the failing test
 it still prompted me to send a report)

note: the config.m4 patch is a quick and dirty fix for debian, unfortunately 
there is not
yet any cross-distro way to retrive the multiarch triplet (mostly because other 
distros
have not yet accepted multiarch).

A patch is attatched containing all the fixes listed above.

diff -urN ffmpeg-php-0.6.0/debian/patches/find_multiarch_libavcodec.so.patch ffmpeg-php-0.6.0.new/debian/patches/find_multiarch_libavcodec.so.patch
--- ffmpeg-php-0.6.0/debian/patches/find_multiarch_libavcodec.so.patch	1970-01-01 00:00:00.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/patches/find_multiarch_libavcodec.so.patch	2011-12-31 23:30:57.000000000 +0000
@@ -0,0 +1,15 @@
+Index: ffmpeg-php-0.6.0/config.m4
+===================================================================
+--- ffmpeg-php-0.6.0.orig/config.m4	2008-10-14 02:47:18.000000000 +0000
++++ ffmpeg-php-0.6.0/config.m4	2011-12-31 23:30:54.000000000 +0000
+@@ -65,6 +65,10 @@
+     if test -f $i/lib/libavcodec.dylib; then
+       FFMPEG_LIBDIR=$i/lib
+     fi
++    DEB_HOST_MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH`
++    if test -f $i/lib/$DEB_HOST_MULTIARCH/libavcodec.so; then
++      FFMPEG_LIBDIR=$i/lib/$DEB_HOST_MULTIARCH
++    fi
+     done
+ 
+     PHP_ADD_LIBRARY_WITH_PATH(avcodec, $FFMPEG_LIBDIR, FFMPEG_SHARED_LIBADD)
diff -urN ffmpeg-php-0.6.0/debian/patches/fix_ftbfs_libav-0.7.patch ffmpeg-php-0.6.0.new/debian/patches/fix_ftbfs_libav-0.7.patch
--- ffmpeg-php-0.6.0/debian/patches/fix_ftbfs_libav-0.7.patch	1970-01-01 00:00:00.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/patches/fix_ftbfs_libav-0.7.patch	2011-12-31 23:28:55.000000000 +0000
@@ -0,0 +1,293 @@
+Description: Fix FTFS with libav 0.7 because of undefined CODEC_TYPE_*,
+ PKT_FLAG_KEY, hurry_up and MAX_STREAMS variables as well as datas (comment,
+ title, author, album, copyright, genre, track, year) in AVFormatContext
+ (replaced by av_dict_get functions)
+Author: Fabrice Coutadeur <fabric...@ubuntu.com>
+
+Index: ffmpeg-php-0.6.0/ffmpeg_movie.c
+===================================================================
+--- ffmpeg-php-0.6.0.orig/ffmpeg_movie.c	2011-09-03 17:01:53.000000000 +0000
++++ ffmpeg-php-0.6.0/ffmpeg_movie.c	2011-09-03 17:12:05.000000000 +0000
+@@ -45,6 +45,10 @@
+ 
+ #include "ffmpeg_frame.h"
+ #include "ffmpeg_movie.h"
++
++#if LIBAVFORMAT_VERSION_MAJOR >= 53
++#define MAX_STREAMS 20	/* arbitrary sanity check value */
++#endif
+    
+ #define GET_MOVIE_RESOURCE(ff_movie_ctx) {\
+     zval **_tmp_zval;\
+@@ -149,7 +153,7 @@
+  */
+ static AVStream *_php_get_video_stream(AVFormatContext *fmt_ctx)
+ {
+-    int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_VIDEO);
++    int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_VIDEO);
+     
+     return i < 0 ? NULL : fmt_ctx->streams[i];
+ }
+@@ -162,7 +166,7 @@
+  */
+ static AVStream *_php_get_audio_stream(AVFormatContext *fmt_ctx)
+ {
+-    int i = _php_get_stream_index(fmt_ctx, CODEC_TYPE_AUDIO);
++    int i = _php_get_stream_index(fmt_ctx, AVMEDIA_TYPE_AUDIO);
+     
+     return i < 0 ? NULL : fmt_ctx->streams[i];
+ }
+@@ -481,7 +485,7 @@
+     stream_index = _php_get_stream_index(ffmovie_ctx->fmt_ctx, stream_type);
+     if (stream_index < 0) {
+         // FIXME: factor out the conditional.
+-        if (stream_type == CODEC_TYPE_VIDEO) {
++        if (stream_type == AVMEDIA_TYPE_VIDEO) {
+             zend_error(E_WARNING, "Can't find video stream in %s", 
+                     _php_get_filename(ffmovie_ctx));
+             return NULL;
+@@ -528,8 +532,8 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+     
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->comment,
+-            strlen(ffmovie_ctx->fmt_ctx->comment), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "comment", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "comment", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -543,8 +547,8 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->title,
+-            strlen(ffmovie_ctx->fmt_ctx->title), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "title", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "title", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -558,8 +562,8 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->author,
+-            strlen(ffmovie_ctx->fmt_ctx->author), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "artist", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "artist", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -572,8 +576,8 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->copyright,
+-            strlen(ffmovie_ctx->fmt_ctx->copyright), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "copyright", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "copyright", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -587,8 +591,8 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->album,
+-            strlen(ffmovie_ctx->fmt_ctx->album), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "album", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "album", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -601,8 +605,8 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    RETURN_STRINGL(ffmovie_ctx->fmt_ctx->genre,
+-            strlen(ffmovie_ctx->fmt_ctx->genre), 1);
++    RETURN_STRINGL(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "genre", NULL, 0)->value,
++            strlen(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "genre", NULL, 0)->value), 1);
+ }
+ /* }}} */
+ 
+@@ -616,7 +620,7 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+     
+-    RETURN_LONG(ffmovie_ctx->fmt_ctx->track);
++    RETURN_LONG(strtol(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "track", NULL, 0)->value, NULL, 10));
+ }
+ /* }}} */
+ 
+@@ -629,7 +633,7 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+     
+-    RETURN_LONG(ffmovie_ctx->fmt_ctx->year);
++    RETURN_LONG(strtol(av_dict_get(ffmovie_ctx->fmt_ctx->metadata, "date", NULL, 0)->value, NULL, 10));
+ }
+ /* }}} */
+ 
+@@ -675,7 +679,7 @@
+     }
+ 
+ #if LIBAVCODEC_BUILD > 4753 
+-    if (GET_CODEC_FIELD(st->codec, codec_type) == CODEC_TYPE_VIDEO){
++    if (GET_CODEC_FIELD(st->codec, codec_type) == AVMEDIA_TYPE_VIDEO){
+         if (st->r_frame_rate.den && st->r_frame_rate.num) {
+             rate = av_q2d(st->r_frame_rate);
+         } else {
+@@ -807,7 +811,7 @@
+ {
+     AVCodecContext *decoder_ctx = NULL;
+ 
+-    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+     if (!decoder_ctx) {
+         return 0;
+     }
+@@ -847,7 +851,7 @@
+ {
+     AVCodecContext *decoder_ctx;
+     
+-    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+ 
+     return decoder_ctx ? decoder_ctx->pix_fmt : 0;
+ }
+@@ -960,7 +964,7 @@
+         codec_name = decoder_ctx->codec_name;
+     } else {
+         /* output avi tags */
+-        if (decoder_ctx->codec_type == CODEC_TYPE_VIDEO) {
++        if (decoder_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+             snprintf(buf1, sizeof(buf1), "%c%c%c%c",
+                     decoder_ctx->codec_tag & 0xff,
+                     (decoder_ctx->codec_tag >> 8) & 0xff,
+@@ -986,7 +990,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+  
+     if (codec_name) {
+         RETURN_STRINGL(codec_name, strlen(codec_name), 1);
+@@ -1006,7 +1010,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    codec_name = (char*)_php_get_codec_name(ffmovie_ctx, CODEC_TYPE_AUDIO);
++    codec_name = (char*)_php_get_codec_name(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
+  
+     if (codec_name) {
+         RETURN_STRINGL(codec_name, strlen(codec_name), 1);
+@@ -1026,7 +1030,7 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+    
+-    stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_VIDEO); 
++    stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_VIDEO);
+ 
+ 	if( stream_id == -1 )
+ 	{
+@@ -1048,7 +1052,7 @@
+     
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+    
+-    stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, CODEC_TYPE_AUDIO); 
++    stream_id= _php_get_stream_index(ffmovie_ctx->fmt_ctx, AVMEDIA_TYPE_AUDIO);
+ 
+ 	if( stream_id == -1 )
+ 	{
+@@ -1086,7 +1090,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    channels = _php_get_codec_channels(ffmovie_ctx, CODEC_TYPE_AUDIO);
++    channels = _php_get_codec_channels(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
+  
+     if (channels) {
+         RETURN_LONG(channels);
+@@ -1122,7 +1126,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, CODEC_TYPE_AUDIO);
++    sample_rate = _php_get_codec_sample_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
+  
+     if (sample_rate) {
+         RETURN_LONG(sample_rate);
+@@ -1158,7 +1162,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_AUDIO);
++    bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_AUDIO);
+  
+     if (bit_rate) {
+         RETURN_LONG(bit_rate);
+@@ -1178,7 +1182,7 @@
+ 
+     GET_MOVIE_RESOURCE(ffmovie_ctx);
+ 
+-    bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    bit_rate = _php_get_codec_bit_rate(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+  
+     if (bit_rate) {
+         RETURN_LONG(bit_rate);
+@@ -1201,7 +1205,7 @@
+     int got_frame; 
+ 
+     video_stream = _php_get_stream_index(ffmovie_ctx->fmt_ctx, 
+-            CODEC_TYPE_VIDEO);
++            AVMEDIA_TYPE_VIDEO);
+     if (video_stream < 0) {
+         return NULL;
+     }
+@@ -1212,11 +1216,10 @@
+     while (av_read_frame(ffmovie_ctx->fmt_ctx, &packet) >= 0) {
+         if (packet.stream_index == video_stream) {
+         
+-            avcodec_decode_video(decoder_ctx, frame, &got_frame,
+-                    packet.data, packet.size);
++            avcodec_decode_video2(decoder_ctx, frame, &got_frame, &packet);
+         
+             if (got_frame) {
+-                *is_keyframe = (packet.flags & PKT_FLAG_KEY);
++                *is_keyframe = (packet.flags & AV_PKT_FLAG_KEY);
+                 *pts = packet.pts;
+                 av_free_packet(&packet);
+                 return frame;
+@@ -1243,7 +1246,7 @@
+     AVCodecContext *decoder_ctx = NULL;
+     AVFrame *frame = NULL;
+ 
+-    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+     if (decoder_ctx == NULL) {
+         return NULL;
+     }
+@@ -1279,9 +1282,9 @@
+                 wanted_frame != GETFRAME_NEXTFRAME &&
+                 wanted_frame - ffmovie_ctx->frame_number > 
+                 decoder_ctx->gop_size + 1) {
+-            decoder_ctx->hurry_up = 1;
++            decoder_ctx->skip_frame = AVDISCARD_NONREF;
+         } else {
+-            decoder_ctx->hurry_up = 0;
++            decoder_ctx->skip_frame = AVDISCARD_DEFAULT;
+         }
+         ffmovie_ctx->frame_number++; 
+ 
+@@ -1440,7 +1443,7 @@
+     AVCodecContext *decoder_ctx;
+ 	
+ 
+-    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, CODEC_TYPE_VIDEO);
++    decoder_ctx = _php_get_decoder_context(ffmovie_ctx, AVMEDIA_TYPE_VIDEO);
+     if (!decoder_ctx) {
+         return -1;
+     }
diff -urN ffmpeg-php-0.6.0/debian/patches/fix_ftbfs_pix_fmt_rgba32.patch ffmpeg-php-0.6.0.new/debian/patches/fix_ftbfs_pix_fmt_rgba32.patch
--- ffmpeg-php-0.6.0/debian/patches/fix_ftbfs_pix_fmt_rgba32.patch	1970-01-01 00:00:00.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/patches/fix_ftbfs_pix_fmt_rgba32.patch	2011-12-31 23:28:55.000000000 +0000
@@ -0,0 +1,47 @@
+Description: Fix FTBFS with ffmpeg >= 0.6 as it doesn't define PIX_FMT_RGBA32 anymore.
+Author: Felix Geyer <debfx-...@fobos.de>
+Origin: backport, http://ffmpeg-php.svn.sourceforge.net/viewvc/ffmpeg-php?view=rev&revision=677
+
+diff -Nur ffmpeg-php-0.6.0/ffmpeg_frame.c ffmpeg-php-0.6.0.patch/ffmpeg_frame.c
+--- ffmpeg-php-0.6.0/ffmpeg_frame.c	2008-10-14 01:02:01.000000000 +0200
++++ ffmpeg-php-0.6.0.patch/ffmpeg_frame.c	2010-06-03 16:13:17.596647216 +0200
+@@ -60,6 +60,12 @@
+     ZEND_FETCH_RESOURCE(gd_img, gdImagePtr, ret, -1, "Image", le_gd); \
+ }
+ 
++#if PIX_FMT_RGBA32
++#define FFMPEG_PHP_FFMPEG_RGB_PIX_FORMAT PIX_FMT_RGBA32
++#else
++#define FFMPEG_PHP_FFMPEG_RGB_PIX_FORMAT PIX_FMT_RGB32
++#endif
++
+ // Borrowed from gd.c
+ #define gdImageBoundsSafeMacro(im, x, y) (!((((y) < (im)->cy1) || ((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))
+ 
+@@ -333,7 +339,7 @@
+ 
+     GET_FRAME_RESOURCE(getThis(), ff_frame);
+ 
+-    _php_convert_frame(ff_frame, PIX_FMT_RGBA32);
++    _php_convert_frame(ff_frame, FFMPEG_PHP_FFMPEG_RGB_PIX_FORMAT);
+ 
+     return_value->value.lval = _php_get_gd_image(ff_frame->width, 
+             ff_frame->height);
+@@ -418,7 +424,7 @@
+ 
+             /* create a an av_frame and allocate space for it */
+             frame = avcodec_alloc_frame();
+-            avpicture_alloc((AVPicture*)frame, PIX_FMT_RGBA32, width, height);
++            avpicture_alloc((AVPicture*)frame, FFMPEG_PHP_FFMPEG_RGB_PIX_FORMAT, width, height);
+ 
+             /* copy the gd image to the av_frame */
+             _php_gd_image_to_avframe(gd_img, frame, width, height);
+@@ -429,7 +435,7 @@
+             /* set the ffpmeg_frame's properties */
+             ff_frame->width = width;
+             ff_frame->height = height;
+-            ff_frame->pixel_format = PIX_FMT_RGBA32;
++            ff_frame->pixel_format = FFMPEG_PHP_FFMPEG_RGB_PIX_FORMAT;
+             break;
+         default:
+             zend_error(E_ERROR, "Invalid argument\n");
diff -urN ffmpeg-php-0.6.0/debian/patches/fix_id3_test.patch ffmpeg-php-0.6.0.new/debian/patches/fix_id3_test.patch
--- ffmpeg-php-0.6.0/debian/patches/fix_id3_test.patch	1970-01-01 00:00:00.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/patches/fix_id3_test.patch	2011-12-31 23:34:04.000000000 +0000
@@ -0,0 +1,12 @@
+Index: ffmpeg-php-0.6.0/tests/getID3Info.phpt
+===================================================================
+--- ffmpeg-php-0.6.0.orig/tests/getID3Info.phpt	2011-12-31 23:31:50.000000000 +0000
++++ ffmpeg-php-0.6.0/tests/getID3Info.phpt	2011-12-31 23:34:00.000000000 +0000
+@@ -20,6 +20,6 @@
+ ffmpeg getTitle(): Test mp3
+ ffmpeg getArtist(): Alexander Thomas
+ ffmpeg getAlbum(): MP3 test files (http://www.dr-lex.be/software/testsounds.html#Tones)
+-ffmpeg getGenre(): (37)
++ffmpeg getGenre(): Sound Clip
+ ffmpeg getTrackNumber(): 3
+ ffmpeg getYear(): 2008
diff -urN ffmpeg-php-0.6.0/debian/patches/series ffmpeg-php-0.6.0.new/debian/patches/series
--- ffmpeg-php-0.6.0/debian/patches/series	2011-12-31 23:36:11.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/patches/series	2011-12-31 23:32:56.000000000 +0000
@@ -1,3 +1,7 @@
 allow_persistent_on_persistentMovie.phpt.patch
 gdtoimage_fix.patch
 test_fixes.patch
+fix_ftbfs_pix_fmt_rgba32.patch
+fix_ftbfs_libav-0.7.patch
+find_multiarch_libavcodec.so.patch
+fix_id3_test.patch
diff -urN ffmpeg-php-0.6.0/debian/rules ffmpeg-php-0.6.0.new/debian/rules
--- ffmpeg-php-0.6.0/debian/rules	2011-12-31 23:36:11.000000000 +0000
+++ ffmpeg-php-0.6.0.new/debian/rules	2011-12-31 23:29:05.000000000 +0000
@@ -33,7 +33,7 @@
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
 	# prevent php from throwing warnings, causing the tests to fail
 	ln -s $(PHP_EX)/*.so $(CURDIR)/modules/
-	$(MAKE) test 2>&1 | tee test-results.txt
+	NO_INTERACTION=1 $(MAKE) test 2>&1 | tee test-results.txt
 	# Print the failed tests output:
 	@sed -r 's,^ffmpeg\s+[^\[]+\s+\[(tests/\w+)\.phpt\]$$,\1.log,g' \
 		< test-results.txt | egrep "^tests/.*\.log" | \

Reply via email to