robbiepaul / cloudconvert-laravel

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

video thumbnail not generated with command #29

Closed bachras closed 8 years ago

bachras commented 8 years ago

Hi,

I am trying to create a thumbnail. It works perfectly fine until I add command(), then video is created but folder and image is not created. Do you know how to resolve this issue? Maybe I am doing something wrong, or it is expected behaviour?

Here is my code:

$width = 1280;
$height = 720;
$basename = rand ( 1 , 10000 );

$cloudConvert = CloudConvert::file($file)
                      ->command('-i {INPUTFILE} -filter:v "scale=iw*min('.$width.'/iw\,'.$height.'/ih):ih*min('.$width.'/iw\,'.$height.'/ih), pad='.$width.':'.$height.':('.$width.'-iw*min('.$width.'/iw\,'.$height.'/ih))/2:('.$height.'-ih*min('.$width.'/iw\,'.$height.'/ih))/2" {OUTPUTFILE}')
                      ->withOptions([
                           'thumbnail_count' => '1',
                           'thumbnail_size' => '640x480',
                           'thumbnail_format' => 'png' ])
                      ->callback('https://url.com')
                      ->convert(CloudConvert::s3($basename.'.mp4'));

Any help would be highly appreciated. Thanks

robbiepaul commented 8 years ago

@bachras I think this is probably because CloudConvert uses it's own command to create the thumbnail. Can you complete the task using the CloudConvert API console? Does it work then?

bachras commented 8 years ago

@robbiepaul I just tried on CloudConvert API console and it is the same behaviour. I tried to make a thunbnail using command as well but conversion fails due to mp4 to png conversion. Do you have any suggestion?

I have also another questions. Is there is a way to convert file to to three different formats using same process. At the minute main code looks like this:


$cloudConvert = CloudConvert::file($file)
                         ->command('-i {INPUTFILE} -filter:v "scale=iw*min('.$width.'/iw\,'.$height.'
/ih):ih*min('.$width.'/iw\,'.$height.'/ih), pad='.$width.':'.$height.':('.$width.'-iw*min('.$width.'/iw\,'.$height.'
/ih))/2:('.$height.'-ih*min('.$width.'/iw\,'.$height.'/ih))/2" {OUTPUTFILE}')
                          ->callback('https://url.com/')
                          ->convert(CloudConvert::s3($basename.'.mp4'));

Thank you

josiasmontag commented 8 years ago

@bachras

If you use the command option, all other options (including the thumbnail options) are ignored. Because of this you need to start 2 conversions: One for the actual video conversion (with your command) and one for creating the thumbnail.

In general a CloudConvert Processes is strictly for converting one file, so you cannot create multiple resolutions with just one process. Please have a look at this example, which is exactly doing what you want to achieve.

For further questions regarding this please contact support@cloudconvert.com. Your issue is not directly related to the laravel wrapper.

bachras commented 8 years ago

@josiasmontag Thanks for clarifying that.