4

I am trying to execute a job that will transcode a video file. I have a php file:

<?php
require 'vendor/autoload.php';

use Aws\ElasticTranscoder\ElasticTranscoderClient;

// Create a service locator using a configuration file
$client = ElasticTranscoderClient::factory(array(
        'key'    => 'my key',
        'secret' => 'my secret',
        'region' => 'us-west-2',
));

$result = $client->createJob(array(
        'PipelineId' => 'my pipeline id',
        'Input' => array(
                'Key' => 'video.mp4',
                'FrameRate' => 'auto',
                'Resolution' => 'auto',
                'AspectRatio' => 'auto', 
                'Interlaced' => 'auto',
                'Container' => 'auto',
        ),
        'Output' => array(
                'Key' => 'output.mp4',
                'ThumbnailPattern' => 'thumb{count}.jpg',
                'Rotate' => 'auto',
                'PresetId' => '1351620000001-000010',
        ),
));

?>

and I call this script like transcoder.php

The thing is that if I call this from my root from VPS like php transcoder.php it works just fine, but if I try to call it from my browser (safari, chrome, firefox) I get a

Fatal error: Uncaught exception 'Aws\ElasticTranscoder\Exception\ElasticTranscoderException' in /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php:91 

Stack trace: 

#0 /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php(76): Aws\Common\Exception\NamespaceExceptionFactory->createException('Aws\ElasticTran...', Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response), Array) 

#1 /home/my_user/public_html/test/vendor/aws/aws-sdk-php/src/Aws/Common/Exception/ExceptionListener.php(55): Aws\Common\Exception\NamespaceExceptionFactory->fromResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response)) 

#2 [internal function]: Aws\Common\Exception\ExceptionListener->onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher)) 

#3 /home/my_user/public_html/test/vendor/symfony/event-dispatcher/Symfony/Component/Even in /home/my_user/public_html/test/transcoder.php on line 35

Why does it work from root and but not from browser? I need to access it from the browser.

starball
  • 20,030
  • 7
  • 43
  • 238
Catalin
  • 1,821
  • 4
  • 26
  • 32

2 Answers2

1

Try changing the settings from php.ini regarding curl and exec, that`s why you dont have permission to access the script from the browser, but works from root console.

Alex
  • 1,033
  • 4
  • 23
  • 43
0

Firstly, put a try/catch statement around the code to see the whole error message which will help diagnose the problem.

I suspect it's because the files you are passing in Key do not exist as the working directory can be different if you execute on the command line vs apache.

Try specifying the full path to video.mp4 and see if that works.

fire
  • 21,383
  • 17
  • 79
  • 114
  • the files from Key are files from the amazon S3 bucket... not local files – Catalin Apr 22 '14 at 11:24
  • ah my bad, either way use try/catch to get the full error message – fire Apr 22 '14 at 11:47
  • I edited my post, please check it again, added the full message – Catalin Apr 22 '14 at 12:04
  • thats not showing the error message from the exception thrown... http://stackoverflow.com/questions/9041173/throwing-exceptions-in-a-php-try-catch-block – fire Apr 22 '14 at 13:18
  • the message is empty, only the stack can show some info... it seems that changing some settings in php.ini does the trick – Catalin Apr 22 '14 at 18:25