renderingvideo/sdk
Composer 安装命令:
composer require renderingvideo/sdk
包简介
Official PHP SDK for RenderingVideo API - Video rendering and generation service
README 文档
README
Official PHP SDK for the RenderingVideo API - a powerful video rendering and generation service.
Requirements
- PHP 8.0 or higher
- Composer
Installation
Install via Composer:
composer require renderingvideo/sdk
Quick Start
<?php require 'vendor/autoload.php'; use RenderingVideo\SDK\Client; // Initialize the client with your API key $client = new Client('sk-your-api-key');
Authentication
Get your API key from Settings > API Keys.
$client = new Client('sk-your-api-key', [ 'base_url' => 'https://renderingvideo.com', // Optional: custom base URL 'timeout' => 30, // Optional: request timeout in seconds ]);
Usage
Video Tasks
Create a Video Task
$task = $client->video->create([ 'meta' => [ 'version' => '2.0.0', 'width' => 1920, 'height' => 1080, 'fps' => 30, 'background' => '#000000', ], 'tracks' => [ [ 'clips' => [ [ 'type' => 'text', 'text' => 'Hello World', 'start' => 0, 'duration' => 5, ], ], ], ], ], [ 'project_id' => 'proj_123', // Optional metadata ]); echo $task->taskId; // abc123def456 echo $task->previewUrl; // https://video.renderingvideo.com/v/abc123def456 echo $task->status; // created
List Video Tasks
$taskList = $client->video->list([ 'page' => 1, 'limit' => 20, 'status' => 'completed', // Filter by status ]); foreach ($taskList->tasks as $task) { echo $task->taskId . ': ' . $task->status . PHP_EOL; } echo "Total: " . $taskList->total; echo "Has more: " . ($taskList->hasMore() ? 'yes' : 'no');
Get Task Details
$task = $client->video->get('abc123def456'); echo $task->status; // completed, rendering, created, failed echo $task->videoUrl; // Available when completed echo $task->costCredits; // Credits used
Trigger Rendering
$renderResult = $client->video->render('abc123def456', [ 'webhook_url' => 'https://your-server.com/webhook', // Optional 'num_workers' => 5, // Optional ]); echo $renderResult->status; // rendering echo $renderResult->remainingCredits; // 970
Wait for Completion
// Blocking call that polls until completion $task = $client->video->waitForCompletion( 'abc123def456', timeout: 300, // Max wait time in seconds interval: 5, // Polling interval in seconds ); if ($task->isCompleted()) { echo "Video ready: " . $task->videoUrl; }
Delete a Task
$result = $client->video->delete('abc123def456'); echo $result['deleted']; // true echo $result['remoteDeleted']; // true
File Uploads
Upload Files
// Single file $result = $client->files->upload('/path/to/image.png'); // Multiple files $result = $client->files->upload([ '/path/to/image.png', '/path/to/video.mp4', ]); $firstFile = $result->getFirst(); echo $firstFile->id; // asset_001 echo $firstFile->url; // https://storage.../images/... echo $firstFile->getReadableSize(); // 123.45 KB
Upload from Content
$content = file_get_contents('/path/to/file.png'); $result = $client->files->uploadFromContent($content, 'my-image.png');
List Files
$fileList = $client->files->list([ 'page' => 1, 'limit' => 20, 'type' => 'image', // Filter: image, video, audio ]); foreach ($fileList->files as $file) { echo $file->name . ' (' . $file->getReadableSize() . ')' . PHP_EOL; }
Delete a File
$result = $client->files->delete('asset_001');
Preview Links
Create a Preview
$preview = $client->preview->create([ 'meta' => [ 'version' => '2.0.0', 'width' => 1920, 'height' => 1080, 'fps' => 30, ], 'tracks' => [...], ]); echo $preview->tempId; // temp_abc123 echo $preview->previewUrl; // https://video.renderingvideo.com/t/temp_abc123 echo $preview->expiresIn; // 7d
Get Preview Config
$config = $client->preview->get('temp_abc123');
Convert Preview to Permanent Task
$task = $client->preview->convert('temp_abc123', [ 'category' => 'my-category', // Optional ]); echo $task->taskId;
Convert and Render Immediately
$renderResult = $client->preview->render('temp_abc123', [ 'webhook_url' => 'https://your-server.com/webhook', 'num_workers' => 5, ]);
Delete Preview
$result = $client->preview->delete('temp_abc123');
Credits
Check Balance
$balance = $client->credits->get(); echo $balance->credits; // 985 echo $balance->currency; // credits
Calculate Cost
// Calculate credits needed for a render $cost = $client->credits->calculateCost( duration: 10, // seconds width: 1920, height: 1080 ); echo $cost; // 15 credits (10 seconds × 1.5 multiplier for 1080p)
Check Affordability
$canAfford = $client->credits->canAfford(10, 1920, 1080); if ($canAfford) { // Proceed with render }
Error Handling
use RenderingVideo\SDK\Exceptions\ApiException; use RenderingVideo\SDK\Exceptions\AuthenticationException; use RenderingVideo\SDK\Exceptions\InsufficientCreditsException; use RenderingVideo\SDK\Exceptions\NotFoundException; use RenderingVideo\SDK\Exceptions\ValidationException; try { $task = $client->video->get('invalid-id'); } catch (NotFoundException $e) { echo "Task not found: " . $e->getMessage(); } catch (InsufficientCreditsException $e) { echo "Not enough credits: " . $e->getMessage(); } catch (ValidationException $e) { echo "Validation error: " . $e->getMessage(); print_r($e->getDetails()); } catch (AuthenticationException $e) { echo "Authentication failed: " . $e->getMessage(); } catch (ApiException $e) { echo "API error ({$e->getErrorCode()}): " . $e->getMessage(); }
Error Codes
| Code | Exception | Description |
|---|---|---|
MISSING_API_KEY |
AuthenticationException | No API key provided |
INVALID_API_KEY |
AuthenticationException | Invalid or revoked API key |
INSUFFICIENT_CREDITS |
InsufficientCreditsException | Not enough credits |
NOT_FOUND |
NotFoundException | Resource not found |
INVALID_CONFIG |
ValidationException | Invalid video configuration |
ALREADY_RENDERING |
ValidationException | Task is already rendering |
Webhook Notifications
When rendering completes or fails, the webhook URL receives a POST request:
// Your webhook endpoint $payload = json_decode(file_get_contents('php://input'), true); $taskId = $payload['taskId']; $status = $payload['status']; // 'completed' or 'failed' $videoUrl = $payload['videoUrl']; // Available on success $error = $payload['error']; // Available on failure $timestamp = $payload['timestamp'];
Credit Calculation
Credits are calculated as:
Cost = Duration (seconds) × Quality Multiplier
| Quality | Short Edge | Multiplier |
|---|---|---|
| 720p | ≥720px | 1.0 |
| 1080p | ≥1080px | 1.5 |
| 2K | ≥1440px | 2.0 |
Development
Run Tests
composer install
composer test
Code Style
composer check-style composer fix-style
License
MIT License. See LICENSE for details.
Support
- Documentation: https://renderingvideo.com/docs
- API Reference: https://renderingvideo.com/docs/api-reference
- Support: support@renderingvideo.com
renderingvideo/sdk 适用场景与选型建议
renderingvideo/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sdk」 「video」 「Rendering」 「renderingvideo」 「json-to-video」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 renderingvideo/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 renderingvideo/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 renderingvideo/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
The yii2-videojs-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
A PSR-7 compatible library for making CRUD API endpoints
Display a video using native HTML5 video
TYPO3 Plugin that displays YouTube-videos faster by loading the video-player on demand while displaying a cacheable preview picture.
The yii2-alipay-widget is a Yii 2 wrapper for the [video.js](http://www.videojs.com/). A JavaScript and CSS library that makes it easier to work with and build on HTML5 video. This is also known as an HTML5 Video Player.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-27