簡體   English   中英

php亞馬遜彈性轉碼器

[英]php amazon elastic transcoder

我正在嘗試執行一個對視頻文件進行轉碼的工作......我有一個 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',
        ),
));

?>

我把這個腳本稱為 transcoder.php

問題是,如果我從 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

知道為什么它可以從 root 運行以及為什么它不能在瀏覽器中運行嗎? 我需要從瀏覽器訪問它。

嘗試從 php.ini 更改有關 curl 和 exec 的設置,這就是為什么您無權從瀏覽器訪問腳本,但可以從根控制台訪問。

首先,在代碼周圍放置一個try/catch 語句以查看整個錯誤消息,這將有助於診斷問題。

我懷疑這是因為您在Key中傳遞的文件不存在,因為如果您在命令行與 apache 上執行,工作目錄可能會有所不同。

嘗試指定video.mp4的完整路徑,看看是否有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM