lakshmaji / thumbnail Goto Github PK
View Code? Open in Web Editor NEWThumbnail for a given video using FFMpeg
Home Page: http://lakshmaji.github.io/Thumbnail
License: MIT License
Thumbnail for a given video using FFMpeg
Home Page: http://lakshmaji.github.io/Thumbnail
License: MIT License
Was wondering what the reason was for the throw in the thumbnail.php if there is an error?
Its a bit of a show stopper. If you try to make multiple images from a list of mp4s, and there is an error, eg file name incorrect, or is a dead link, the function stops. Would be good to have some set up to allow that to just return an error?
Best
It's resizing with height of 400, but in my thumbnail.php I've set dimensions.height to 240. What can it be?
I have follow each and every step while installing this package. i have also run
php artisan vendor:publish
it generated the "thumbnail.php" file in app/config.
i have also inlcuded FFMPEG configuration in .env file
FFMPEG_BINARIES=true
FFMPEG=/usr/bin/ffmpeg
FFPROBE=/usr/bin/ffprobe
FFMPEG_TIMEOUT=3600
FFMPEG_THREADS=12
by doing all these , getThumbanil() method isn't working. can you please guide me ?
i am using:
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
Dear Lakshmaji,
I got this problem and I hope you can help me solve it:
After uploading the video to get the thumbnail I got this error:
FatalThrowableError in Thumbnail.php line 55: Class 'FFMpeg\FFMpeg\FFMpeg' not found
My configuration in .env is:
`##thumbnail video
#Thumbnail image dimensions
THUMBNAIL_IMAGE_WIDTH = 320
THUMBNAIL_IMAGE_HEIGHT = 240
#Custom FFMPEG binaries path
FFMPEG_BINARIES=true
FFMPEG_PATH=C:\ffmpeg\bin\ffmpeg
FFPROBE_PATH=C:\ffmpeg\bin\ffprobe
FFMPEG_TIMEOUT=3600
FFMPEG_THREADS=12`
Thank you so much!
As I see getThumbnail()
function, it doesn't accept width and height as argument,
Can anyone guide me how can I set the width and height of the image?
$video_path = $path . '/' .$filename;
$thumbnail_path = public_path().'/uploads/tutorial-thumbnails';
$thumbnail_filename = $originalFilenameWithExt . '.jpg';
$time_to_image = 1;
$thumbnail_width = 320;
$thumbnail_height = 240;
$thumbnail = new Thumbnail();
$thumbnail_status = $thumbnail->getThumbnail($video_path, $thumbnail_path, $thumbnail_filename, $time_to_image);
Thanks in Advance
It is possible to receive thumnail from a remote file (youtube, dailymotion, Vimeo, etc...) ?
Hi man,
I cant make a PR right now, but ThumbnailServiceProvider.php needs to be updated in order to compatible with Laravel 5.4.
Replace
$this->app['thumbnail'] = $this->app->share(function($app) {
return new Thumbnail;
});
With
$this->app->singleton('thumbnail', function($app) {
return new Thumbnail;
});
Should be working then.
Seriously, I'm pulling my hair out knowing what is wrong with my code. I noticed these issues when I was supplying videos below 10 seconds. Thumbnail::getThumbnail says it is successful but it is not generating an image. I looked into the source code until I saw the default seconds in $tts variable was 10 seconds.
Solution for this is supply the fourth argument with 0
Thumbnail::getThumbnail($video_path, $thumbnail_path, $thumbnail_file_name, 0);
I got Width and height should be positive integer
While Using This Lib.
I already Added width & height in .env
My Laravel version is 8
The package version is 1.4.51
Thumbnail image dimensions doesn't work...
Hello
I am writing code with Laravel and I am not able to retrieve your latest merge (of branch adepolas-patch-2) from composer.
I've done a composer update. But the class Thumbnail.php remains the same.
Do you know why ?
Hi, I am currently having problems getting thumbnail image from path on Windows, can someone assist me?
Url "http://beta.ads.api.techres.vn:3002/public/resource/ALOLINE/REVIEW_MEDIA/0/0/2021/3/24-3-2021/video/original/VID_076875fb32e323c911d1a537417864b2.mp4"
Not working with laravel 5.8. Status true but image not created in server. no issue when running but image not created from destination folder.
my code is like below please check it and correct me if i'm wrong
public function index(Request $request)
{
$file = $request->file('file');
$fb_user_id = 'user';
$extension_type = $file->getClientMimeType();
$destination_path = public_path().'/uploads';
$extension = $file->getClientOriginalExtension();
$timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
$file_name = $timestamp;
$upload_status = $file->move($destination_path, $file_name);
if($upload_status)
{
// file type is video
// set storage path to store the file (image generated for a given video)
$thumbnail_path = public_path().'/images';
$video_path = $destination_path.'/'.$file_name;
// set thumbnail image name
$thumbnail_image = $file_name.".jpg";
// $fp = fopen($thumbnail_path.'/'.$thumbnail_image, "w");
// dd($thumbnail_path.'/'.$thumbnail_image);
// set the thumbnail image "palyback" video button
$water_mark = public_path().'/watermark/p.png';
// get video length and process it
// assign the value to time_to_image (which will get screenshot of video at that specified seconds)
$time_to_image = '100';
$thumbnail_status = Thumbnail::getThumbnail($video_path,$thumbnail_path,$thumbnail_image);
// dd($thumbnail_status);
if($thumbnail_status)
{
echo "Thumbnail generated";
}
else
{
echo "thumbnail generation has failed";
}
}
// dd($file_name);
}`
I am using this library in laravel & getting error
"Width and height should be positive integer"
Here is my code:-
public function thumb()
{
$watermark = public_path('/assets/images_upload/1535017656.png');
$thumbnail_status = Thumbnail::getThumbnail(public_path('/assets/images_upload/1535450453.mp4'),public_path('/assets/thumbnail'),"pic.jpg",160,128,2,$watermark,true);
if($thumbnail_status)
{
echo "Thumbnail generated";
}
else
{
echo "thumbnail generation has failed";
}
}
Here is my code
$movie = 'https://jogobucket-1.s3.eu-west-2.amazonaws.com/media/exercise/DV2/JOGO_D3.2_v2.mp4';
$thumbnail = new Thumbnail();
echo $thumbnail->getThumbnail($movie,public_path().'uploads','test.png',30);
The error is:
"message": "Unable to probe https://jogobucket-1.s3.eu-west-2.amazonaws.com/media/exercise/DV2/JOGO_D3.2_v2.mp4",
"exception": "Exception",
"file": "C:\wamp64\www\JOGO-PHP\vendor\lakshmaji\thumbnail\src\Thumbnail.php",
"line": 109,
Hi every one, i noticed a mini delay when generating the thumbnail. Here is my situation: I 'm building a URL that accept media and from the media title I do a thumbnail from video or thumbnail from image depends of the mime_content_type. The plugin works fine but just asking is it normal to have let say 1 to 2 sec of delay. When i do the thumbnail from image it's super fast and when i do it with Thumbnails it take 1 to 2 sec to do it.
Here is a video to take a look.
Any help would help.
Thank you
can i use it for laravel 5.8
Hi,
Could you add support for Laravel 5.6 ?
Thanks a lot.
I am trying to make a thumbnail from live streaming video, and i ended up here to try using it.
I followed the instruction of installation up to composer require lakshmajim/thumbnail
.
Should I create a php file in my server and copy all the codes you provide in Thumbnail.php file that is in src folder?
Could you guide me a little bit for me?
throw new Exception("Got bad cookie");
the code is hidden the real error message.
i advise you delete try catch code.
Can you please release a latest version from you current master branch ?
Because v1.4.4 is still having the following line : FFMpeg\FFMpeg::create
Instead of : FFMpeg::create (currently on master)
It may fix almost all the 'Bad Cookie' errors.
Thanks ! ๐
FatalThrowableError in Thumbnail.php line 84: Call to undefined function Lakshmaji\Thumbnail\imagecreatefrompng()
Ubuntu 16.4 php 7
Hi again
Got bad cookie in /vendor/lakshmaji/thumbnail/src/Thumbnail.php:109
I haven't changed anything, just did the update for the package and it is broken. I am getting the "Got bad cookie" error..
Hello, I am trying to generate a thumbnail with this code
$path = $request->media->store($mediaPath);
// generate thumbnail
$videoPath = storage_path('app/public/').$path;
$thumbnailPath = storage_path('app/public/');
$thumbnailImage = now()->timestamp.".jpg";
$time_to_image = 1;
$t_status = Thumbnail::getThumbnail($videoPath, $thumbnailPath, $thumbnailImage, $time_to_image);
if($t_status) {
$media->path = $path;
$media->thumbnail_path = $thumbnailPath.$thumbnailImage;
$media->type = 'video';
} else {
return response()->json(['error' => true]);
}
However, I keep getting Width and height should be positive integer
.
I am using Laravel 7 and PHP 7.4
I am trying to create thumbnail image with the Laravel file storage system , but it does not work with the file already store on the disk let say public or s3 i get the following error
Exception: Unable to probe http://anotaistore.dev/storage/video/TbLAgDTXT1EDCiANartUe5gdTo76gRqn1CoTb7PC.mp4
the code is
public function store(Request $request, Video $video)
{
//Authorize the valide user
$this->authorize('upload', Video::class);
// Validate the request
$data = request()->validate([
'video' => 'required|mimeTypes:video/mp4|max:204800',
'title' => 'required',
'description' => 'required',
]);
//
$file = request()->file('video');
// Store the file to the disk
$storedFile = $file->store('video', 'public');
// set storage path to store the file (actual video)
$storage = Storage::disk('public');
$path = $storage->url($storedFile);
$thumbnail_image = $file->hashName() . ".jpg";
$thumbnail_path = 'tempo';
// This file is in project folder named tempo
$file_in_project_folder = 'tempo/Alhimyri.mp4';
Thumbnail::getThumbnail($path, $thumbnail_path, $thumbnail_image);
// Append the url to data to be stored
$dataToRecord = [
'title' => $data['title'],
'description' => $data['description'],
'url' => $path,
];
auth()->user()->createVideo($dataToRecord);
return response(['Okay', 200]);
}
Please help what prevent generation thumnail from the disk,
But when i use the $file_in_project_folder = 'tempo/Alhimyri.mp4'; instead of $path on
Thumbnail::getThumbnail($path, $thumbnail_path, $thumbnail_image);
as
Thumbnail::getThumbnail($file_in_project_folder, $thumbnail_path, $thumbnail_image);
everthing work perfectly what is the issue here
Any idea?
This is probably a user error -- but maybe, maybe it's a bug.
I am not able to get the thumbnails to be resized.
Here is my thumbnail.php
<?php
/*
|--------------------------------------------------------------------------
| File which returns array of constants containing the thumbnail
| integration configurations.
|--------------------------------------------------------------------------
|
*/
return array(
/*
|--------------------------------------------------------------------------
| FFMPEG BINARIES CONFIGURATIONS
|--------------------------------------------------------------------------
|
| If you want to give binary paths explicitly, you can configure the FFMPEG
| binary paths set to the below 'env' varibales.
|
| NOTE: FFMpeg will autodetect ffmpeg and ffprobe binaries.
|
*/
'binaries' => [
'enabled' => env('FFMPEG_BINARIES', false),
'path' => [
'ffmpeg' => env('FFMPEG_PATH', '/opt/local/ffmpeg/bin/ffmpeg'),
'ffprobe' => env('FFPROBE_PATH', '/opt/local/ffmpeg/bin/ffprobe'),
'timeout' => env('FFMPEG_TIMEOUT', 3600), // The timeout for the underlying process
'threads' => env('FFMPEG_THREADS', 12), // The number of threads that FFMpeg should use
],
],
/*
|--------------------------------------------------------------------------
| Thumbnail image dimensions
|--------------------------------------------------------------------------
|
| Specify the dimensions for thumbnail image
|
*/
'dimensions' => [
'width' => env('THUMBNAIL_IMAGE_WIDTH', 800),
'height' => env('THUMBNAIL_IMAGE_HEIGHT', 800),
],
/*
|--------------------------------------------------------------------------
| Thumbnail watermark alpha
|--------------------------------------------------------------------------
|
| Specify the secret THUMBNAIL_X
|
*/
'watermark' => [
'image' => [
'enabled' => env('WATERMARK_IMAGE', false),
'path' => env('WATERMARK_PATH', 'http://voluntarydba.com/pics/YouTube%20Play%20Button%20Overlay.png'),
],
'video' => [
'enabled' => env('WATERMARK_VIDEO', false),
'path' => env('WATERMARK_PATH', ''),
],
],
/*
|--------------------------------------------------------------------------
| Thumbnail some x
|--------------------------------------------------------------------------
|
| Specify the secret THUMBNAIL_X
|
*/
'THUMBNAIL_X' => '<YOUR_THUMBNAIL_X>',
);
// php artisan vendor:publish
// end of file thumbnail.php
Here is my env file
...
#Custom FFMPEG binaries path
FFMPEG_BINARIES = true
FFMPEG_PATH = /usr/local/bin/ffmpeg
FFPROBE_PATH = /usr/local/bin/ffprobe
FFMPEG_TIMEOUT = 3600
FFMPEG_THREADS = 12
...
The thumbnail files are being generated, but they are the size of the video. I'd love to have them dropped to a square format.
Laravel Framework 6.16.0
Unable to load FFProbe
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.