12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class VideoThumbnailsPlugin extends Plugin
- {
-
- public function onCreateFileImageThumbnailSource(File $file, &$imgPath, $media=null)
- {
-
-
- if ($media !== 'video') {
- return true;
- }
- $movie = new ffmpeg_movie($file->getPath(), false);
- $frames = $movie->getFrameCount();
- if ($frames > 0) {
- $frame = $movie->getFrame(floor($frames/2));
- } else {
- $frame = $movie->getNextKeyFrame();
- }
-
- if (!$frame instanceof ffmpeg_frame) {
- return true;
- }
-
- $imgPath = tempnam(sys_get_temp_dir(), 'socialthumb');
- if (!imagejpeg($frame->toGDImage(), $imgPath)) {
- @unlink($imgPath);
- return true;
- }
- return false;
- }
- public function onPluginVersion(&$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;
- }
- }
|