robbiepaul / cloudconvert-laravel

A Laravel wrapper for the CloudConvert API
177 stars 34 forks source link

Creating video thumbnail without converting #30

Open hermanschutte opened 8 years ago

hermanschutte commented 8 years ago

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.

robbiepaul commented 8 years ago

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?

hermanschutte commented 8 years ago

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

robbiepaul commented 8 years ago

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

hermanschutte commented 8 years ago

Perfect, thanks.

bachras commented 8 years ago

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

robbiepaul commented 8 years ago

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.

bachras commented 8 years ago

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

bachras commented 8 years ago

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

robbiepaul commented 8 years ago

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();
bachras commented 8 years ago

@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

robbiepaul commented 8 years ago

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.

josiasmontag commented 8 years ago

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

bachras commented 8 years ago

@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?

josiasmontag commented 8 years ago

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

robbiepaul commented 8 years ago

@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();
bachras commented 8 years ago

@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

robbiepaul commented 8 years ago

Yeah will do

bachras commented 8 years ago

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

robbiepaul commented 8 years ago

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

bachras commented 8 years ago

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

robbiepaul commented 8 years ago

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

chrisbell08 commented 7 years ago

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

rizwanmcs commented 7 years ago

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

robbiepaul commented 7 years ago

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

lucaswiix commented 5 years ago

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