{"id":14974711,"url":"https://github.com/lakshmaji/thumbnail","last_synced_at":"2025-04-06T02:08:16.649Z","repository":{"id":8503448,"uuid":"58640818","full_name":"lakshmaji/Thumbnail","owner":"lakshmaji","description":"Thumbnail for a given video using FFMpeg","archived":false,"fork":false,"pushed_at":"2022-11-24T11:16:24.000Z","size":90,"stargazers_count":109,"open_issues_count":11,"forks_count":25,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-06T02:08:11.799Z","etag":null,"topics":["centos","composer","ffmpeg","generating-thumbnails","laravel","laravel-framework","multimedia","php","thumbnail","ubuntu1404","ubuntu1604","video","watermark"],"latest_commit_sha":null,"homepage":"http://lakshmaji.github.io/Thumbnail","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lakshmaji.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-12T12:46:48.000Z","updated_at":"2025-02-26T10:28:15.000Z","dependencies_parsed_at":"2023-01-13T14:50:15.333Z","dependency_job_id":null,"html_url":"https://github.com/lakshmaji/Thumbnail","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakshmaji%2FThumbnail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakshmaji%2FThumbnail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakshmaji%2FThumbnail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lakshmaji%2FThumbnail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lakshmaji","download_url":"https://codeload.github.com/lakshmaji/Thumbnail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423514,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["centos","composer","ffmpeg","generating-thumbnails","laravel","laravel-framework","multimedia","php","thumbnail","ubuntu1404","ubuntu1604","video","watermark"],"created_at":"2024-09-24T13:50:58.422Z","updated_at":"2025-04-06T02:08:16.625Z","avatar_url":"https://github.com/lakshmaji.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thumbnail\n\n[![Latest Stable Version](https://poser.pugx.org/lakshmajim/thumbnail/v/stable)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![Total Downloads](https://poser.pugx.org/lakshmajim/thumbnail/downloads)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![Latest Unstable Version](https://poser.pugx.org/lakshmajim/thumbnail/v/unstable)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![License](https://poser.pugx.org/lakshmajim/thumbnail/license)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![Monthly Downloads](https://poser.pugx.org/lakshmajim/thumbnail/d/monthly)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![Daily Downloads](https://poser.pugx.org/lakshmajim/thumbnail/d/daily)](https://packagist.org/packages/lakshmajim/thumbnail)\n[![composer.lock](https://poser.pugx.org/lakshmajim/thumbnail/composerlock)](https://packagist.org/packages/lakshmajim/thumbnail)\n\n[Wiki on web](http://lakshmaji.github.io/Thumbnail/)\n\n\u003e### INDEX\n\n|Index|Description|\n|---|---|\n|[What it is](https://github.com/lakshmaji/Thumbnail#what-it-is) |- Introduction|\n|[Installing FFMpeg](https://github.com/lakshmaji/Thumbnail#installing-dependency-software) |- Installing dependency software|\n|[Installation](https://github.com/lakshmaji/Thumbnail#installation) |- Installing Thumbnail package, Lararavel Integration|\n|[Docs](https://github.com/lakshmaji/Thumbnail#method)|- Methods and Description|\n|[Generating Thumbnail](https://github.com/lakshmaji/Thumbnail#genearting-thumbnail) |- Generating thumbnail image with this package|\n|[Miscellaneous](https://github.com/lakshmaji/Thumbnail#miscellaneous) |- Miscellaneous content regarding method calls|\n|[License](https://github.com/lakshmaji/Thumbnail#license) |- License Information|\n\n\n\n\u003e### What it is\n\n - Generates Thumbnail (image) for a given video \n - This uses **FFMpeg**.\n - Converts video to WebM format.\n\n\u003e### Version\n\n1.4.5\n\n\u003e### Compatibility\n\n**Laravel version**     | **Thumbnail version**\n-------- | ---\n5.6    | 1.4.5\n5.5    | 1.4.5\n5.4    | 1.4.5\n5.2    | 1.4.5 or 1.4.2 or 1.3.0\n5.1    | 1.4.5 or 1.4.2 or 1.3.0\n5.0    | 1.4.5 or 1.4.2 or 1.3.0\n\n**Note:** For **1.4.3** and other **earlier** version documentation refer [here](https://github.com/lakshmaji/Thumbnail/blob/4ec692054a6541bb46eae6802a2b09138ce156b8/README.md) \n\n---\n\u003e### Installing dependency software\n\nThis package relays on [FFMpeg](https://en.wikipedia.org/wiki/FFmpeg), A complete, cross-platform solution to record, convert and stream audio and video i.e, Multimedia .\n\n#### Installing FFMpeg on  16.04 (Xenial Xerus) LTS\n\n- Run following command to install FFMpeg\n\n  ```bash\n  sudo apt-get update\n  sudo apt-get install ffmpeg\n  ```\n\n#### Installing FFMpeg on Ubuntu 14.04  LTS\n\n- Add the mc3man ppa\n\n  ```bash\n  sudo add-apt-repository ppa:mc3man/trusty-media\n  ```\n        \n- Run following command to Update the package list. \n\n  ```bash\n  sudo apt-get update\n  sudo apt-get update sudo apt-get dist-upgrade\n  ```\n        \n- Now FFmpeg is available to be installed with **apt** , Run this command\n\n  ```terminal\n  sudo apt-get install ffmpeg\n  ```\n\n#### Installing FFMpeg on CentOS \n- Enable EPEL repository \n   - for centos 6\n     \n     ```bash\n        rpm -Uvh http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm\n     ```\n   - for centos 5\n     \n     ```bash\n        rpm -Uvh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm\n     ```\n   - for centos 7\n     \n     ```bash\n        yum install epel-release\n     ```\n\n- Check whether EPEL respository is eabled by the following command\n\n  ```bas\n     yum repolist\n  ```\n\n- Import the official GPG key of Nux Dextop repository:\n\n  ```bash\n     rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro\n  ```\n   \n   \n##### Nux Dextop is a third-party RPM repository which contains many popular desktop and multimedia related packages (e.g., Ardour, Shutter, etc) for CentOS, RHEL and ScientificLinux. Currently, Nux Dextop repository is available for CentOS/RHEL 6 and 7.\n   \n   \n- Install Nux Dextop with yum command as follows.\n    - centos 6\n    \n      ```bash\n      rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm\n      ```\n    - centos 7\n    \n      ```bash\n      rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm\n      ```\n    \n- Now verify that Nux Dextop repository is successfully installed:\n    \n    ```bash\n       yum repolist\n    ```\n    \n- Run following command to install FFMpeg\n    \n    ```bash\n       yum install ffmpeg\n    ```\n    \n    \n\n#### Installing FFMpeg on Windows\n\n Refer to the following links\n \n [WikiHow](http://www.wikihow.com/Install-FFmpeg-on-Windows) \n\n [AdapticeSolutions](http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/)\n\n        \n---\n\u003e### Installation\n\n- This package is available on packagist\n```bash\n    composer require lakshmaji/thumbnail\n```\n- Add the Service Provider to **providers** array\n```php\nLakshmaji\\Thumbnail\\ThumbnailServiceProvider::class,\n```\n- Add the Facade to **aliases** array\n```php\n'Thumbnail' =\u003e Lakshmaji\\Thumbnail\\Facade\\Thumbnail::class,\n```\n- Try updating the application with composer (dependencies but not mandatory :wink:  )\n```bash\n  composer update\n```\n\n---\n\n\n---\n\u003e### Configurations\n\n- Publish the configuration file , this will publish thumbnail.php file to your application **config** directory.\n```bash\n    php artisan vendor:publish\n```\n- Configure the required FFMpeg configurations.\n - FFMpeg will autodetect ffmpeg and ffprobe binaries. If you want to give binary paths explicitly, you can configure them in **.env** file.\n - You can specify the output image dimensions in .env file. (dimensions array parameters)\n - Add watermark or playback button url to **watermark** arry aviable in thumbnail.php\n - Or you can configure them from laravel .env file, the sample watermark resource configurations in .env file \n```bash\n#Thumbnail image dimensions\nTHUMBNAIL_IMAGE_WIDTH  = 320\nTHUMBNAIL_IMAGE_HEIGHT = 240\n\n#Watermark image\nWATERMARK_IMAGE = true\nWATERMARK_PATH  = /var/www/html/thumb/storage/watermark/p.png\n\n#Custom FFMPEG binaries path\nFFMPEG_BINARIES = true\nFFMPEG_PATH     = /opt/local/ffmpeg/bin/ffmpeg\nFFPROBE_PATH    = /opt/local/ffmpeg/bin/ffprobe\nFFMPEG_TIMEOUT  = 3600\nFFMPEG_THREADS  = 12\n```\nThis ensures that all the generated thumbnails with watermarks are having fixed dimensions\n\n---\n\n\n\n\u003e### Generating Thumbnail\n\nThe following example illustrates the usage of Thumbnail package\n\n```php\n\n\u003c?php \n\nnamespace Trending\\Http\\Controllers\\File;\n\nuse Carbon;\nuse Thumbnail;\nuse Illuminate\\Http\\Request;\nuse Trending\\Http\\Controllers\\Controller;\n\n\n/**\n * -----------------------------------------------------------------------------\n *   ThumbnailTest - a class illustarting the usage og Thumbnail package \n * -----------------------------------------------------------------------------\n * This class having the functionality to upload a video file \n * and generate corresponding thumbnail\n *\n * @since    1.0.0\n * @version  1.0.0\n * @author   lakshmaji \n */\nclass ThumbnailTest extends AnotherClass\n{\n  public function testThumbnail()\n  {\n    // get file from input data\n    $file             = $this-\u003erequest-\u003efile('file');\n\n    // get file type\n    $extension_type   = $file-\u003egetClientMimeType();\n    \n    // set storage path to store the file (actual video)\n    $destination_path = storage_path().'/uploads';\n\n    // get file extension\n    $extension        = $file-\u003egetClientOriginalExtension();\n\n\n    $timestamp        = str_replace([' ', ':'], '-', Carbon::now()-\u003etoDateTimeString());\n    $file_name        = $timestamp;\n    \n    $upload_status    = $file-\u003emove($destination_path, $file_name);         \n\n    if($upload_status)\n    {\n      // file type is video\n      // set storage path to store the file (image generated for a given video)\n      $thumbnail_path   = storage_path().'/images';\n\n      $video_path       = $destination_path.'/'.$file_name;\n\n      // set thumbnail image name\n      $thumbnail_image  = $fb_user_id.\".\".$timestamp.\".jpg\";\n      \n      // set the thumbnail image \"palyback\" video button\n      $water_mark       = storage_path().'/watermark/p.png';\n\n      // get video length and process it\n      // assign the value to time_to_image (which will get screenshot of video at that specified seconds)\n      $time_to_image    = floor(($data['video_length'])/2);\n\n\n      $thumbnail_status = Thumbnail::getThumbnail($video_path,$thumbnail_path,$thumbnail_image,$time_to_image);\n      if($thumbnail_status)\n      {\n        echo \"Thumbnail generated\";\n      }\n      else\n      {\n        echo \"thumbnail generation has failed\";\n      }\n    }\n  }\n}\n// end of class ThumbnailTest\n// end of file ThumbnailTest.php  \n```\n\n---\n\u003e### METHOD\n\n```php\n$thumbnail_status = Thumbnail::getThumbnail(\u003cVIDEO_SOURCE_DIRECTORY\u003e,\u003cTHUMBNAIL_STORAGE_DIRECTORY\u003e,\u003cTHUMBNAIL_NAME\u003e);\n```\n\n```php\n$thumbnail_status = Thumbnail::getThumbnail(\u003cVIDEO_SOURCE_DIRECTORY\u003e,\u003cTHUMBNAIL_STORAGE_DIRECTORY\u003e,\u003cTHUMBNAIL_NAME\u003e,\u003cTIME_TO_TAKE_SCREENSHOT\u003e);\n\n```\n\n| PARAMETER           | DESCRIPTION                             |FIELD |\n|:-------------- |:----------------------------------------|:---|\n|VIDEO_SOURCE_DIRECTORY |     Video resource source path i.e, the name of video along with location where video is present|mandatory| \n| THUMBNAIL_STORAGE_DIRECTORY|    The destination path to save the generated thumbnail image|mandatory|\n| THUMBNAIL_NAME | The name of Image for output|mandatory|\n| TIME_TO_TAKE_SCREENSHOT    |         Time to take screenshot of the video               | optional|\nthumbnail image| optional|\n\n**Note** : Some of the method parameters are deprecated from version 1.4.4. For earlier versions of this package (\u003c=1.4.3) refer [here](https://github.com/lakshmaji/Thumbnail/blob/4ec692054a6541bb46eae6802a2b09138ce156b8/README.md). The watermark and output image (thumbnail image) dimensions can be configured from **app/config.php** file.\n\n\n----\n\u003e### MISCELLANEOUS\n\n- To generate the thumbnail image ( screen shot of video) with playback button\n  - Your controller class\n  ```php\n  Thumbnail::getThumbnail($video_path,$thumbnail_path,$thumbnail_image,$time_to_image);\n  ```\n  - Your config file\n  ``` php\n  'watermark' =\u003e [\n          'image' =\u003e [\n              'enabled' =\u003e env('WATERMARK_IMAGE', true),\n              'path'    =\u003e env('WATERMARK_PATH', 'http://voluntarydba.com/pics/YouTube%20Play%20Button%20Overlay.png'),\n          ],\n          'video' =\u003e [\n              'enabled' =\u003e env('WATERMARK_VIDEO', false),\n              'path'    =\u003e env('WATERMARK_PATH', ''),\n          ],\n  ],\n  ```\n- To generate the thumbnail image ( screen shot of video)\n```php\n  Thumbnail::getThumbnail($video_path,$thumbnail_path,$thumbnail_image);\n```\n\n- To convert video to WebM format\n```php\n            $video_path = $destination_path.'/'.$file_name; // source video path\n                        $clipped_video  = $destination_path.'/'.'clipped_'.$file_name; // converted video file\n \nThumbnail::clipWebM($video_path,$clipped_video);\n```\n\n\n\n----\n\u003e### LICENSE\n\n[MIT](https://opensource.org/licenses/MIT)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakshmaji%2Fthumbnail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flakshmaji%2Fthumbnail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flakshmaji%2Fthumbnail/lists"}