corbpie / gumlet-api
Gumlet 视频托管 API 封装器
0.9
2024-03-15 02:05 UTC
Requires
- php: ^8.2
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-12 14:58:34 UTC
README
请注意,此软件包仍在开发中!
目录
特性
创建和更新视频与配置文件...
安装与使用
使用 composer 安装
composer require corbpie/gumlet-api
使用示例
require __DIR__ . '/vendor/autoload.php'; use Corbpie\Gumlet; $gm = new Gumlet\GumletVideo();
设置 API 密钥
第 7 行 GumletBase.php
const API_KEY = 'XXXX-XXXX-XXXX';
视频
列出配置文件
$gm->listProfiles();
设置配置文件
需要设置 $gm->profile_id
$gm->profile_id = 'TJQuvxBnOcxQwnPOWc';
获取配置文件
需要设置 $gm->profile_id
$gm->getProfile();
创建配置文件
$parameters = [ 'description' => 'The description for this new profile', 'mp4_access' => true ]; $format = 'HLS';//HLS, MPEG-DASH, MP4 $gm->createProfile('the-new-profile-name', $format, $parameters);
列出视频
需要设置 $gm->video_collection
$gm->listVideos();
获取视频详情
$gm->video_id = '65f1819d759d13a91c0a4c09'; echo json_encode($gm->getVideo());
从 URL 创建视频
需要 $url 和 $gm->video_collection
$gm->createVideoFromUrl($url, $format, $parameters);
输入
注意设置 $gm->profile_id 将覆盖除 $url 和集合 ID 之外的所有内容
string
$url
下载视频的 URL。
string
$format
视频编码格式 "HLS, MPEG-DASH 和 MP4" 仅限!
array
$parameters
视频创建的可选值
[
'tag'=> 'example, another',
'title'=> 'title to video',
'description'=> 'This video is all about XYZ',
'width'=> '75%',
'height'=> '75%',
'resolution'=> '720p',
'mp4_access'=> true,
'per_title_encoding'=> false,
'process_low_resolution_input'=> true,
'audio_only'=> false,
'enable_drm'=> true
]
从 URL 创建包含多个音频轨道的视频的示例
$parameters = [ 'profile_id' => '65138fa952ccfd817db2a665', 'title' => 'The title for this great video', 'description' => 'The description for this great video', 'mp4_access' => false, 'audio_only' => false, 'additional_tracks' => [ [ 'url' => 'https://gumlet.sgp1.digitaloceanspaces.com/video/sample_1.aac', 'type' => 'audio', 'language_code' => 'en', 'name' => 'English'], [ 'url' => 'https://gumlet.sgp1.digitaloceanspaces.com/video/sample_1.aac', 'type' => 'audio', 'language_code' => 'pl', 'name' => 'Polish' ] ] ]; $video = $gm->createVideoFromUrl( 'https://domain.com/video.mp4', 'MP4', $parameters );
从帧更新缩略图
$gm->video_id = '65f1819d759d13a91c0a4c09'; $frame = 20; $gm->updateVideoThumbnailFromFrame($frame);
更新视频标题
$gm->video_id = '65f1819d759d13a91c0a4c09'; $gm->updateVideoTitle('The new title for this video');
更新视频描述
$gm->video_id = '65f1819d759d13a91c0a4c09'; $gm->updateVideoDescription('The new description for this video');
删除视频
$gm->video_id = '65f1819d759d13a91c0a4c09'; $gm->deleteVideo();