Package: video
Generated from api/packages/video
Source: api/packages/video · imported version 0.0.23. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”What does it do
Section titled “What does it do”Coverts TopicVideo into HLS stream.
Installing
Section titled “Installing”composer require ulams/video
Requirements
Section titled “Requirements”ffmpegmust be installed- Once
Ulams\TopicType\TopicTypeChangedis dispatched job ProccessVideo added to queue
Configuration
Section titled “Configuration”You can configure the quality and resolution of the processed video by setting values in config.php file under the bitrates key. The key takes arrays of values.
kiloBitratesparameter is responsible for the video quality.scaleparameter is responsible for video resolution, setting this parameter may cause video distortion.
You can also disable video processing or change the drive.
Example config:
return [ 'disk' => env('VIDEO_DISK', config('filesystems.default')), 'enable' => env('VIDEO_PROCESSING_ENABLE', true), 'bitrates' => [ [ 'kiloBitrate' => 250, // video quality 'scale' => '640:480' // This parameter changes the video resolution. You can omit this parameter. ], ... ]];Example
Section titled “Example”This package extends API resources in Ulams\TopicType package.
\Ulams\TopicTypes\Http\Resources\TopicType\Client\VideoResource- replaces value and url fields with hls values
{ "id": 1, "value": "course/1/topic/1/video/hls.m3u8", "url": "https://ulams.app/course/1/topic/1/video/hls.m3u8"}\Ulams\TopicTypes\Http\Resources\TopicType\Admin\VideoResource- adds hls values
{ "id": 1, "value": "course/1/topic/1/video/video.mp4", "url": "https://ulams.app/course/1/topic/1/video/video.mp4", "hls": "course/1/topic/1/video/hls.m3u8", "hls_url": "https://ulams.app/course/1/topic/1/video/hls.m3u8"}The processing status is saved in the json field in the topics table:
- Processing successful
{ "ffmpeg": { "state": "finished", "path": "course/1/topic/1/video/hls.m3u8" }}- Processing failed
{ "ffmpeg": { "state" : "error", "message" : "Unable to probe /path/video.mp4" }}Run ./vendor/bin/phpunit to run tests. See tests folder as it’s quite good staring point as documentation appendix.
Test details
Events
Section titled “Events”ProcessVideoStarted- event dispatched after processing startedProcessVideoFailed- event dispatched after processing failed
More documentation in the package
Section titled “More documentation in the package”Topic types
Section titled “Topic types”Video
API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
GET |
/api/admin/video/states |
yes | VideoController@states |
Permissions
Section titled “Permissions”| Permission | Seeded for roles | Constant |
|---|---|---|
video_process-states-list |
admin | VideoPermissionEnum::VIDEO_PROCESS_STATES_LIST |
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
| Key | Rules | Public | Read-only |
|---|---|---|---|
ulams_video.bitrates |
array | no | |
ulams_video.enable |
boolean | no | |
ulams_video.non_strict_value |
boolean | no |
Events
Section titled “Events”| Event | Description | Notification templates |
|---|---|---|
ProcessVideoFailed |
||
ProcessVideoFinished |
||
ProcessVideoStarted |
||
ProcessVideoState |
Notification templates registered here
Section titled “Notification templates registered here”None.
Artisan commands
Section titled “Artisan commands”None.
Scheduled jobs
Section titled “Scheduled jobs”| Kind | Target | Frequency |
|---|---|---|
| job | DetectStuckVideo::class |
everyThirtyMinutes() |
Environment variables read
Section titled “Environment variables read”VIDEO_DISK, VIDEO_NON_STRICT_VALUE, VIDEO_PROCESSING_ENABLE, VIDEO_QUEUE, VIDEO_QUEUE_CONNECTION