문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top