12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class VideoThumbnailsPlugin extends Plugin
- {
-
- public function onCreateFileImageThumbnailSource(File $file, &$imgPath, $media=null)
- {
-
-
- if ($media !== 'video' || empty($file->filename)) {
- return true;
- }
-
- $tmp_imgPath = tempnam(sys_get_temp_dir(), 'socialthumb-');
- $cmd = null;
- if (shell_exec('which ffmpeg')) {
- $cmd = 'ffmpeg';
- } elseif (shell_exec('which avconv')) {
- $cmd = 'avconv';
- } else {
- common_log(LOG_ERR, 'Neither ffmpeg nor avconv was found in your PATH. Cannot create video thumbnail.');
- return true;
- }
- $result = exec($cmd.' -y -i '.escapeshellarg($file->getPath()).' -vcodec mjpeg -vframes 1 -f image2 -an '.escapeshellarg($tmp_imgPath));
- if (!getimagesize($tmp_imgPath)) {
- common_debug('exec of "avconv" produced a bad/nonexisting image it seems');
- @unlink($tmp_imgPath);
- return true;
- }
- $imgPath = $tmp_imgPath;
- return false;
- }
- public function onPluginVersion(array &$versions)
- {
- $versions[] = array('name' => 'Video Thumbnails',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Mikael Nordfeldth',
- 'homepage' => 'https://www.gnu.org/software/social/',
- 'rawdescription' =>
-
- _m('Video thumbnail preview support.'));
- return true;
- }
- }
|