The video-thumbnail function causes a php error with certain videos:

PHP Fatal error:  Call to a member function toGDImage() on a non-object in ****/www/sites/all/modules/video/transcoders/TranscoderAbstractionFactoryFfmpeg.inc on line 229

The function-call that fails is getFrame();

$frame = $movie->getFrame(min($frames, (int) $seek * $fps));

The calculated frame number seems to cause the error. Replacing the formular with a fixed value fixes the issue temporarily.

Temporary fix:

$frame = $movie->getFrame(min($frames, (int) $seek * $fps));
if( $frame==false || empty($frame) ){  // getFrame failed...
  $frame = $movie->getFrame(10); // grab frame number 10 instead
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

FreeAndEasy’s picture

Issue summary: View changes

typo

FreeAndEasy’s picture

Issue summary: View changes

typo

Jorrit’s picture

Status: Active » Postponed (maintainer needs more info)

The code you're referring to is only run when the PHP module ffmpeg_movie is installed and the code should have been removed a long time ago. Can you remove this module (if possible for you) and try again?

Jorrit’s picture

Issue summary: View changes

typo

hubobbb’s picture

thank you ,it works .

FreeAndEasy’s picture

Issue summary: View changes

I can't remove the module, but I can confirm that when I remove the code it works again!

FreeAndEasy’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Needs review
FileSize
7.27 KB
joegl’s picture

I just want to confirm that I had this issue (with an older version of the module). All I did was change the following lines of code (224-247 in my version):

        $error = NULL;
        // below code is failing; commented out buggy portion on 2015-03-23
        /*if (class_exists('ffmpeg_movie')) {
          $movie = new ffmpeg_movie($this->transcoder->getInputFile());
          $frames = $movie->getFrameCount();
          $fps = $movie->getFrameRate();
          $frame = $movie->getFrame(min($frames, (int) $seek * $fps));
          $thumb = $frame->toGDImage();
          $result = video_utility::imageSave($thumb, $dstpath, $format);
          if (!$result) {
            $error = t('Unknown FFmpeg-php error');
          }
        }
        else {*/
          $this->transcoder->extractFrame($seek, FALSE, '%st');
          $result = $this->transcoder->setOutput(dirname($dstpath) . '/', basename($dstpath), PHPVideoToolkit::OVERWRITE_EXISTING);
          if ($result === PHPVideoToolkit::RESULT_OK) {
            $result = $this->transcoder->execute() === PHPVideoToolkit::RESULT_OK;
          }

          if (!$result) {
            $error = $this->transcoder->getLastError();
            $this->transcoder->reset(true);
          }
        //}

Notice the comments.

heshanlk’s picture

Component: Video Transcoding » General
Status: Needs review » Needs work