From: Mikael Nordfeldth Date: Wed, 25 Feb 2015 00:36:14 +0000 (+0100) Subject: VideoThumbnails changed to use 'exec' call to avconv X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3bbb748a0884f4b9ecf090562843d3194a7b82af;p=quix0rs-gnu-social.git VideoThumbnails changed to use 'exec' call to avconv --- diff --git a/plugins/VideoThumbnails/VideoThumbnailsPlugin.php b/plugins/VideoThumbnails/VideoThumbnailsPlugin.php index 254931e5fb..758164923d 100644 --- a/plugins/VideoThumbnails/VideoThumbnailsPlugin.php +++ b/plugins/VideoThumbnails/VideoThumbnailsPlugin.php @@ -2,7 +2,7 @@ /** * GNU social - a federating social network * - * Plugin to make thumbnails of video files with ffmpeg + * Plugin to make thumbnails of video files with avconv * * PHP version 5 * @@ -31,10 +31,13 @@ if (!defined('GNUSOCIAL')) { exit(1); } /* * Dependencies: - * php5-ffmpeg + * avconv (external program call) * php5-gd * - * Video support will depend on your ffmpeg. + * Todo: + * Make sure we support ffmpeg too, so we're not super Debian oriented. + * + * Video support will depend on your avconv. */ class VideoThumbnailsPlugin extends Plugin @@ -52,23 +55,13 @@ class VideoThumbnailsPlugin extends Plugin return true; } - $movie = new ffmpeg_movie($file->getPath(), false); + // Let's save our frame to a temporary file. If we fail, remove it. + $imgPath = tempnam(sys_get_temp_dir(), 'socialthumb-'); - $frames = $movie->getFrameCount(); - if ($frames > 0) { - $frame = $movie->getFrame(floor($frames/2)); - } else { - $frame = $movie->getNextKeyFrame(); - } + $result = exec('avconv -i '.escapeshellarg($file->getPath()).' -vcodec mjpeg -vframes 1 -f mjpeg -an '.escapeshellarg($imgPath)); - // We failed to get a frame. - if (!$frame instanceof ffmpeg_frame) { - return true; - } - - // Let's save our frame to a temporary file. If we fail, remove it. - $imgPath = tempnam(sys_get_temp_dir(), 'socialthumb'); - if (!imagejpeg($frame->toGDImage(), $imgPath)) { + if (!getimagesize($imgPath)) { + common_debug('exec of "avconv" produced a bad/nonexisting image it seems'); @unlink($imgPath); return true; }