Unable to call toGDImage()

665 views
Skip to first unread message

JohnnyWang

unread,
Apr 9, 2008, 11:49:00 PM4/9/08
to ffmpeg-php
Hello,

I've tried the solutions found in this group but am still receiving
the following error:

/usr/local/apache2/bin/httpd: symbol lookup error: /usr/local/Zend/
Core/lib/php/20060613/ffmpeg.so: undefined symbol: img_convert

I have compiled ffmpeg with it's default configuration, and based on
the config.h it states:
--enable-swscale software scaler support [default=no]

Any ideas?

Here is my php code:

$movie = new ffmpeg_movie( 'test.flv' );
$numFrames = $movie->getFrameCount();
$randFrameNum = rand( 1, $numFrames );
$frame = $movie->getFrame( $randFrameNum );

if ( $frame instanceof ffmpeg_frame ) {
$gdImg = $frame->toGDImage();
} else {
die('unable to get frame!' );
}

the script dies when calling the toGDImage() function.

Todd Kirby

unread,
Apr 10, 2008, 1:10:21 AM4/10/08
to ffmpe...@googlegroups.com
ffmpeg-php wont work if swscale is enabled.

Jne

unread,
Apr 10, 2008, 4:17:00 AM4/10/08
to ffmpeg-php
I also have this issue on a new box intalled with Debian 64bits

ffmpeg had no been compiled with swscale.

both ffmpeg and ffmpeg-php have been compiled against latest svn
version as of yesterday for ffmpeg and today for ffmpeg-php

code is :

ffmovie = new ffmpeg_movie($input_file, false) or die("sorry we cannot
analyse your file");
$duration = $ffmovie->getDuration();
$img = $ffmovie->getFrame(140);

$img_width = $img->getWidth();
$img_height = $img->getHeight();
$ratio = 150 / $img_width;
$img->resize(150, ((int) ($img_height * $ratio / 2)) * 2);
$imgGD = $img->toGDImage();
--> draws an errror : Fatal error: failed to convert frame to gd image
in test.php on line 9

phpinfo returns
ffmpeg support (ffmpeg-php) enabled
ffmpeg-php version 0.5.2.1
libavcodec version Lavc51.54.0
libavformat version Lavf52.13.0
ffmpeg-php gd support enabled

GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled

help appreciated !


Todd Kirby

unread,
Apr 10, 2008, 7:53:58 AM4/10/08
to ffmpe...@googlegroups.com
ffmpeg-php svn is not stable at the moment. Use 0.5.1 or 0.5.2.1

-T-

Jne

unread,
Apr 10, 2008, 9:03:57 AM4/10/08
to ffmpeg-php
Hi thanks, but 0.5.2.1 was the first version I tried with same effet.

When trying to ./configure 0.5.1 it does not find ffmpeg headers.

JohnnyWang

unread,
Apr 10, 2008, 4:04:41 PM4/10/08
to ffmpeg-php
I do not swscale enabled. I purposely compiled by hand to ensure that
swscale was not being enabled. I am also currently using ffmpeg-
php-0.5.2.1.

joh

unread,
Apr 25, 2008, 8:50:18 AM4/25/08
to ffmpeg-php
Any pdate on this? Did you manage to get it working? I've got the
exact same problem and it seems to fail in _php_avframe_to_gd_image()
in ffmpeg_frame.c:402 on gdImageBoundsSafeMacro().

joh

unread,
Apr 25, 2008, 10:48:44 AM4/25/08
to ffmpeg-php
Discovered that using the previous version of ffmpeg-php: 0.5.1 it
worked perfectly.

Todd Kirby

unread,
Apr 25, 2008, 4:40:01 PM4/25/08
to ffmpe...@googlegroups.com
>I've got the
> exact same problem and it seems to fail in _php_avframe_to_gd_image()
> in ffmpeg_frame.c:402 on gdImageBoundsSafeMacro().
>

Can you post the error that you get.  I've not seen that one before.

oliver...@googlemail.com

unread,
May 21, 2008, 3:22:51 AM5/21/08
to ffmpeg-php
Exists any update?
Ive got the same error.
ffmpeg compiled without swscale (./configure --enabled-shared --
disabled-swscale)
ffmpeg-php version 5.2.1 compilation ok

greg

unread,
Jun 9, 2008, 8:18:08 PM6/9/08
to ffmpeg-php
I'm experiencing the same issue:

ffmpeg-php version 0.5.3
libavcodec version Lavc51.57.1
libavformat version Lavf52.14.0
ffmpeg-php gd support enabled

I'll attempt a down grade and let you know what happens

On Apr 25, 2:40 pm, "Todd Kirby" <ffmpeg....@gmail.com> wrote:
> >I've got the
> > exact same problem and it seems to fail in _php_avframe_to_gd_image()
> > in ffmpeg_frame.c:402 on gdImageBoundsSafeMacro().
>
> Can you post the error that you get. I've not seen that one before.
>

greg

unread,
Jun 13, 2008, 5:23:14 AM6/13/08
to ffmpeg-php
I've tried all available versions of ffmpeg-php. I'm receiving the
same issue with in each version withn PHP 5.2.3-1ubuntu6.3 on mint
4 / ubuntu 7.10. I'll do a fresh install on a remote ubuntu server and
update this thread if I find the issue.

Romain

unread,
Jun 16, 2008, 1:51:38 PM6/16/08
to ffmpeg-php
Got the same problem as everybody

I tried on ffmpeg-php 5.2.1 and 5.3.1, swscale disabled at
compilation.

is anyone got an issue ?

Romain

unread,
Jun 17, 2008, 1:57:41 PM6/17/08
to ffmpeg-php
Hi

First sorry for my bad english, but i got a good news

I was like everybody in this topic, i mean :

Debian etch, php5
I tried to install ffmpeg-php 5.1 5.2.1 5.3.1 lots of time with many
configs, it never worked.

I used to install php and gd with the apt-get.
Today, I tried to install everything from scratch and compile myself
php --with-gd

I installed the ffmpeg-php 5.3.1 and it works !

Try to compile php with gd rathert than load it as module.

I'll try to do it on another station where it didn't work in the past
and i'll keep you informed if it's a real issue.

Romain

Todd Kirby

unread,
Jun 17, 2008, 2:17:04 PM6/17/08
to ffmpe...@googlegroups.com
Hmm so it's not detecting gd when loaded as an extension. There is a configuration option in ffmpeg-php to skip checking for gd at compile time and assume it's installed.

--enable-skip-gd-check

That may work in this situation.

-Todd

Romain

unread,
Jun 18, 2008, 8:14:14 AM6/18/08
to ffmpeg-php
I'll try and give feedback : )

Romain

unread,
Jun 18, 2008, 8:37:59 AM6/18/08
to ffmpeg-php
Hi again

The --enable-skip-gd-check option at compilation does not solve the
problem in my case on that conf :

php5 with gd as module

ffmpeg
ffmpeg support (ffmpeg-php) enabled
ffmpeg-php version 0.5.3.1
libavcodec version Lavc51.57.0
libavformat version Lavf52.14.0
ffmpeg-php gd support enabled

Directive Local Value Master Value
ffmpeg.allow_persistent 0 0
ffmpeg.show_warnings 0 0



gd
GD Support enabled
GD Version 2.0 or higher
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled


When using the toGDimage() methode, get the error "Fatal error: failed
to convert frame to gd image"

volk

unread,
Jun 23, 2008, 5:33:27 AM6/23/08
to ffmpeg-php
I've found a solution:

replace a line 402 in ffmpeg_frame.c as:
...
for( x = 0; x < width; x++ ) {
- : if( dbImageBoundsSafeMacro( dest, x, y ) ) {
+: if( 1 ) {
...

It works.
=)

Todd Kirby

unread,
Jun 23, 2008, 3:03:35 PM6/23/08
to ffmpe...@googlegroups.com
I've backed out the bounds check again in svn. That has been a problem on and off for a long time.

voodoo

unread,
Jul 2, 2008, 4:42:18 PM7/2/08
to ffmpeg-php
I try to make more correct patch. It works:

machine $ diff -u ffmpeg_frame.c.orig ffmpeg_frame.c
--- ffmpeg_frame.c.orig 2008-06-10 05:00:14.000000000 +0400
+++ ffmpeg_frame.c 2008-07-03 00:29:56.000000000 +0400
@@ -59,6 +59,7 @@

// Borrowed from gd.c
#define gdImageBoundsSafeMacro(im, x, y) (!((((y) < (im)->cy1) ||
((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))
+#define gdImageBoundsSafeMacroFixed(x, y, w, h) (!(((y) < 0) || ((y)
>= (h)) || ((x) < 0) || ((x) >= (w))))

static int le_gd; // this is only valid after calling
// FFMPEG_PHP_FETCH_IMAGE_RESOURCE()
@@ -399,7 +400,7 @@
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {

- if (gdImageBoundsSafeMacro(dest, x, y)) {
+ if (gdImageBoundsSafeMacroFixed(x, y, dest-
>sx, dest->sy)) {
/* copy pixel to gdimage buffer zeroing the alpha
channel */
dest->tpixels[y][x] = src[x] & 0x00ffffff;
} else {
machine $

voodoo

unread,
Jul 3, 2008, 1:30:53 AM7/3/08
to ffmpeg-php
Just faster patch, it works too:

machine $ diff -u ffmpeg_frame.c.orig ffmpeg_frame.c
--- ffmpeg_frame.c.orig 2008-06-10 05:00:14.000000000 +0400
+++ ffmpeg_frame.c 2008-07-03 09:20:37.000000000 +0400
@@ -396,15 +396,16 @@
int x, y;
int *src = (int*)frame->data[0];

+ if (width > dest->sx || height > dest->sy)
+ {
+ return -1;
+ }
+
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {

- if (gdImageBoundsSafeMacro(dest, x, y)) {
- /* copy pixel to gdimage buffer zeroing the alpha
channel */
- dest->tpixels[y][x] = src[x] & 0x00ffffff;
- } else {
- return -1;
- }
+ /* copy pixel to gdimage buffer zeroing the alpha channel
*/
+ dest->tpixels[y][x] = src[x] & 0x00ffffff;
}
src += width;
}
machine $
Reply all
Reply to author
Forward
0 new messages