简体   繁体   English

php亚马逊弹性转码器

[英]php amazon elastic transcoder

I am trying to execute a job that will transcoder a video file... I have a php file:我正在尝试执行一个对视频文件进行转码的工作......我有一个 php 文件:

<?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我把这个脚本称为 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问题是,如果我从 VPS 的根调用它,如php transcoder.php,它工作得很好,但是如果我尝试从我的浏览器(safari,chrome,firefox)调用它,我会得到一个

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

Any idea why it works from root and why it doesn't work from browser?知道为什么它可以从 root 运行以及为什么它不能在浏览器中运行吗? I need to access it from browser.我需要从浏览器访问它。

尝试从 php.ini 更改有关 curl 和 exec 的设置,这就是为什么您无权从浏览器访问脚本,但可以从根控制台访问。

Firstly, put a try/catch statement around the code to see the whole error message which will help diagnose the problem.首先,在代码周围放置一个try/catch 语句以查看整个错误消息,这将有助于诊断问题。

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.我怀疑这是因为您在Key中传递的文件不存在,因为如果您在命令行与 apache 上执行,工作目录可能会有所不同。

Try specifying the full path to video.mp4 and see if that works.尝试指定video.mp4的完整路径,看看是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM