php腾讯云直播的录制

tech2024-04-22  325

文档:https://cloud.tencent.com/document/api/267/45981 NOTICE:

录制任务开启后,录制的结果在点播平台

出现:则更换流名称即可。若同一条流当前存在多个时段重叠的任务,为避免重复录制系统将启动最多3个录制任务。

具体流程如下:

安装Composer: windows环境请访问Composer官网下载安装包安装。 【注意】dos下 输入:composer查看是否已经安装成功。第一次安装以后,需要重启。

建议中国大陆地区的用户设置腾讯云镜像源:composer config -g repos.packagist composer https://mirrors.tencent.com/composer/

执行命令 composer require tencentcloud/tencentcloud-sdk-php 添加依赖。

在代码中添加以下引用代码。注意:如下仅为示例,composer 会在项目根目录下生成 vendor 目录,/path/to/为项目根目录的实际绝对路径,如果是在当前目录执行,可以省略绝对路径。

require ‘/path/to/vendor/autoload.php’;

具体代码参考:

require_once 'vendor/autoload.php'; use TencentCloud\Common\Credential; use TencentCloud\Common\Profile\ClientProfile; use TencentCloud\Common\Profile\HttpProfile; use TencentCloud\Common\Exception\TencentCloudSDKException; use TencentCloud\Live\V20180801\LiveClient; use TencentCloud\Live\V20180801\Models\CreateRecordTaskRequest; use TencentCloud\Live\V20180801\Models\StopRecordTaskRequest; $cred = new Credential("参数key", "参数secret"); $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("live.tencentcloudapi.com"); $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); $client = new LiveClient($cred, "ap-guangzhou", $clientProfile); $req = new CreateRecordTaskRequest(); $params = array( "StreamName" => $streamName, "DomainName" => '参数域名', "AppName" => $appName, "EndTime" => time()+3600*12 ); $req->fromJsonString(json_encode($params)); $resp = $client->CreateRecordTask($req); return json_decode($resp->toJsonString(),true);
最新回复(0)