cloudconvert-laravel icon indicating copy to clipboard operation
cloudconvert-laravel copied to clipboard

Creating video thumbnail without converting

Open hermanschutte opened this issue 8 years ago • 25 comments

Is it possible to use this wrapper to create a thumbnail from a video that's already stored on S3? I'm looking at the API docs of CloudConvert, and it seems possible to do it using the normal PHP library, but it seems this wrapper expects an output to be given.

hermanschutte avatar Jun 11 '16 19:06 hermanschutte

If it exists in the API I'm sure I can provide an interface for it. Could you link me to the API docs where it shows how to do it?

robbiepaul avatar Jun 11 '16 19:06 robbiepaul

Thanks! It's here: https://cloudconvert.com/api/videoconversion. In part 1 they deal with just getting the file info and generating the thumbnails.

hermanschutte avatar Jun 11 '16 19:06 hermanschutte

Ah yes, thanks! It seems the info mode is a new API feature. I'll look at introducing it in the next update.

robbiepaul avatar Jun 11 '16 19:06 robbiepaul

Perfect, thanks.

hermanschutte avatar Jun 11 '16 19:06 hermanschutte

That's exactly what I am looking for as well. Looking forward to next update. Thanks

bachras avatar Jul 27 '16 10:07 bachras

Ive actually implemented this already, just haven't committed/tagged it. I'll get it done this evening and let you guys know when it's released.

robbiepaul avatar Jul 28 '16 13:07 robbiepaul

Thank you, I can't wait to try it.

bachras avatar Jul 28 '16 13:07 bachras

Hi @robbiepaul , just wondering when will I be able to try out new feature of video thumbnail? Thank you

bachras avatar Aug 09 '16 15:08 bachras

I've added support for info mode, with creating thumbnails. I'll add the other new modes once I get a chance. It's tagged as v2.3 here fb2ef11f7239738386e22950fccf5bd89ef3cd21

Example usage:

$response = CloudConvert::file('https://server.com/path/to/video.mp4')
                        ->withOptions([
                             "thumbnail_format" => "png",
                             "thumbnail_size" => "200x"
                        ])
                        ->info()
                        ->save('screenshot.png')
                        ->response();

robbiepaul avatar Aug 09 '16 22:08 robbiepaul

@robbiepaul Thank you for quick response and amazing upgrade. It is saving properly on the server, but how can I save it on S3 bucket? And is it possible to do callback for thumbnail in the same way as video callback. Thanks

bachras avatar Aug 10 '16 09:08 bachras

I don't think it's possible as you don't set the output params when making the request to create the thumbnail. Maybe @josiasmontag can confirm?

The not so elegant solution would be to use Laravel's Filesystem to store the thumnail on S3.

robbiepaul avatar Aug 10 '16 10:08 robbiepaul

@robbiepaul You actually can. The output param does work for info mode also and does store the generated thumbnails on the output storage.

josiasmontag avatar Aug 10 '16 10:08 josiasmontag

@josiasmontag I have just tried to create thumbnail on https://cloudconvert.com/page/apivideoconversion but it shows the error. Could you please update me on this?

bachras avatar Aug 10 '16 10:08 bachras

@bachras The used video URL (https://cloudconvert.com/assets...) of the example is broken, otherwise the example works. We will fix that, thanks.

josiasmontag avatar Aug 10 '16 10:08 josiasmontag

@josiasmontag awesome thanks

@bachras in which case this should work, unfortunately I can't test it myself until this evening

$response = CloudConvert::file('https://server.com/path/to/video.mp4')
                        ->withOptions([
                             "thumbnail_format" => "png",
                             "thumbnail_size" => "200x"
                        ])
                        ->setOutput( CloudConvert::S3('screenshot.png') )
                        ->info()
                        ->response();

robbiepaul avatar Aug 10 '16 11:08 robbiepaul

@robbiepaul I would be grateful if you could check saving on S3 in the evening as above code returns me an error. Could you also check create thumbnail from uploaded file as this code:

$files = $request->file('file');
$response = CloudConvert::file($files[0])
                                       ->withOptions([
                                             "thumbnail_format" => "png",
                                              "thumbnail_size" => "100x"
                                        ])
                                       ->info()
                                       ->save('SampleVideo_1280x720_1mb.png')
                                      ->response();

returns this error:

FatalThrowableError in ConvertLocalFile.php line 52:
Fatal error: Call to a member function getFormat() on null
in ConvertLocalFile.php line 52
at ConvertLocalFile->getConversionSettings() in Convert.php line 299
at Convert->toArray() in Process.php line 125
at Process->getInputOptions(object(ConvertLocalFile), null) in Process.php line 85

Many thanks

bachras avatar Aug 10 '16 11:08 bachras

Yeah will do

robbiepaul avatar Aug 10 '16 14:08 robbiepaul

Hi @robbiepaul, Did you have a chance to look at those errors?

bachras avatar Aug 15 '16 07:08 bachras

Not yet my friend, I may have to tag this for v3.0 as alot of the code needs refactoring/rewriting because the API has moved on a bit since I first wrote this wrapper in 2014

robbiepaul avatar Aug 18 '16 14:08 robbiepaul

Thanks for reply, When could I expect v3.0? Many thanks

bachras avatar Aug 18 '16 14:08 bachras

It's hard to put a definite timescale on it, I'm very busy at the moment. I'll make a start on it soon, then open it up to pull requests if people want to contribute

robbiepaul avatar Aug 18 '16 15:08 robbiepaul

Hey Guys,

Has this been looked at yet? I can get the file as a download just struggling to move it to S3, as mentioned above the cloud convert support do say this is possible through there own API.

If not I can go ahead an download the file then push up to s3 with Flysystem just trying to avoid that if poss as it's a little messy

Cheers Chris

chrisbell08 avatar Nov 18 '16 15:11 chrisbell08

Hi Guys! i am new to laravel and i have implemented the cloud converter library on laravel 4.2 version but when i convert my video to gif file on localhost then i face this issue. cURL error 60: SSL certificate problem: unable to get local issuer certificate . can anyone help me about this issue that how i can solve this problem? Thanks

rizwanmcs avatar Jan 16 '17 11:01 rizwanmcs

It could be a firewall issue.

The SSL certificate is fine for CloudConvert domains, even api.cloudconvert.org which the 4.2 version uses for calls

Is there a reason you're still using Laravel 4.2? Version 5 has been out for almost 2 years - it's worth upgrading

robbiepaul avatar Jan 16 '17 13:01 robbiepaul

I am with the same error of rizwanmcs in laravel 5.5. And the api url is https://api.cloudconvert.com/.

lucaswiix avatar Dec 26 '18 02:12 lucaswiix