mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
video scopes
This commit is contained in:
@@ -78,7 +78,7 @@ function validateFilePermissions(Database $dbForProject, string $bucketId, strin
|
||||
App::post('/v1/videos/profiles')
|
||||
->desc('Create video profile')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'createProfile')
|
||||
@@ -118,7 +118,7 @@ App::post('/v1/videos/profiles')
|
||||
App::patch('/v1/videos/profiles/:profileId')
|
||||
->desc('Update video profile')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'updateProfile')
|
||||
@@ -159,7 +159,7 @@ App::patch('/v1/videos/profiles/:profileId')
|
||||
App::get('/v1/videos/profiles/:profileId')
|
||||
->desc('Get video profile')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getProfile')
|
||||
@@ -185,7 +185,7 @@ App::get('/v1/videos/profiles/:profileId')
|
||||
App::get('/v1/videos/profiles')
|
||||
->desc('Get all video profiles')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getProfiles')
|
||||
@@ -213,7 +213,7 @@ App::get('/v1/videos/profiles')
|
||||
App::delete('/v1/videos/profiles/:profileId')
|
||||
->desc('Delete video profile')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.method', 'deleteProfile')
|
||||
@@ -244,7 +244,7 @@ App::delete('/v1/videos/profiles/:profileId')
|
||||
App::post('/v1/videos/:videoId/subtitles')
|
||||
->desc('Add subtitle to video')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'addSubtitle')
|
||||
@@ -293,7 +293,7 @@ App::post('/v1/videos/:videoId/subtitles')
|
||||
App::get('/v1/videos/:videoId/subtitles')
|
||||
->desc('Get all video subtitles')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getSubtitles')
|
||||
@@ -322,7 +322,7 @@ App::get('/v1/videos/:videoId/subtitles')
|
||||
App::patch('/v1/videos/:videoId/subtitles/:subtitleId')
|
||||
->desc('Update video subtitle')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'updateSubtitle')
|
||||
@@ -363,7 +363,7 @@ App::patch('/v1/videos/:videoId/subtitles/:subtitleId')
|
||||
App::delete('/v1/videos/:videoId/subtitles/:subtitleId')
|
||||
->desc('Delete video subtitle')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.method', 'deleteSubtitle')
|
||||
@@ -405,7 +405,7 @@ App::delete('/v1/videos/:videoId/subtitles/:subtitleId')
|
||||
App::get('/v1/videos/buckets/:bucketId')
|
||||
->desc('Get all backet\'s videos')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getVideos')
|
||||
@@ -434,7 +434,7 @@ App::get('/v1/videos/buckets/:bucketId')
|
||||
App::post('/v1/video')
|
||||
->desc('Create Video')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'create')
|
||||
@@ -467,7 +467,7 @@ App::post('/v1/video')
|
||||
App::delete('/v1/videos/:videoId')
|
||||
->desc('Delete video')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.method', 'delete')
|
||||
@@ -507,7 +507,7 @@ App::post('/v1/videos/:videoId/rendition')
|
||||
->alias('/v1/videos/:videoId/rendition', [])
|
||||
->desc('Create video rendition')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'createRendition')
|
||||
@@ -553,7 +553,7 @@ App::post('/v1/videos/:videoId/rendition')
|
||||
App::get('/v1/videos/:videoId/rendition/:renditionId')
|
||||
->desc('Get all backet\'s videos')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getRendition')
|
||||
@@ -591,7 +591,7 @@ App::get('/v1/videos/:videoId/rendition/:renditionId')
|
||||
App::get('/v1/videos/:videoId/renditions')
|
||||
->desc('Get video renditions')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.method', 'getRenditions')
|
||||
@@ -632,7 +632,7 @@ App::get('/v1/videos/:videoId/renditions')
|
||||
App::delete('/v1/videos/:videoId/renditions/:renditionId')
|
||||
->desc('Delete video subtitle')
|
||||
->groups(['api', 'video'])
|
||||
->label('scope', 'files.write')
|
||||
->label('scope', 'videos.write')
|
||||
->label('sdk.namespace', 'video')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.method', 'deleteRendition')
|
||||
@@ -686,7 +686,7 @@ App::get('/v1/videos/:videoId/streams/:streamId')
|
||||
->label('sdk.description', '/docs/references/videos/get-master-manifest.md') // TODO: Create markdown
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->param('videoId', null, new UID(), 'Video unique ID.')
|
||||
->param('streamId', '', new WhiteList(['hls', 'dash']), 'stream protocol name')
|
||||
->inject('response')
|
||||
@@ -804,7 +804,7 @@ App::get('/v1/videos/:videoId/streams/:streamId/renditions/:renditionId')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
// TODO: Response model
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->param('videoId', null, new UID(), 'Video unique ID.')
|
||||
->param('streamId', '', new WhiteList(['hls', 'dash']), 'stream protocol name')
|
||||
->param('renditionId', '', new UID(), 'Rendition unique ID.')
|
||||
@@ -869,7 +869,7 @@ App::get('/v1/videos/:videoId/streams/:streamId/renditions/:renditionId/segments
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
// TODO: Response model
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->param('videoId', null, new UID(), 'Video unique ID.')
|
||||
->param('streamId', '', new WhiteList(['hls', 'dash']), 'stream protocol name')
|
||||
->param('renditionId', '', new UID(), 'Rendition unique ID.')
|
||||
@@ -930,7 +930,7 @@ App::get('/v1/videos/:videoId/streams/:streamId/subtitles/:subtitleId')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
// TODO: Response model
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->param('videoId', null, new UID(), 'Video unique ID.')
|
||||
->param('streamId', '', new WhiteList(['hls', 'dash']), 'stream protocol name')
|
||||
->param('subtitleId', '', new UID(), 'Subtitle unique ID.')
|
||||
@@ -998,7 +998,7 @@ App::get('/v1/videos/:videoId/streams/:streamId/subtitles/:subtitleId/segments/:
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
// TODO: Response model
|
||||
->label('scope', 'files.read')
|
||||
->label('scope', 'videos.read')
|
||||
->param('videoId', null, new UID(), 'Video unique ID.')
|
||||
->param('streamId', '', new WhiteList(['hls', 'dash']), 'stream protocol name')
|
||||
->param('subtitleId', '', new UID(), 'Subtitle unique ID.')
|
||||
|
||||
@@ -38,8 +38,6 @@ class TranscodingV1 extends Worker
|
||||
const STREAM_HLS = 'hls';
|
||||
const STREAM_MPEG_DASH = 'dash';
|
||||
|
||||
const BASE_URL_ENDPOINT = 'http://127.0.0.1/v1/videos';
|
||||
|
||||
//protected string $basePath = '/tmp/';
|
||||
protected string $basePath = '/usr/src/code/tests/tmp/';
|
||||
|
||||
@@ -217,10 +215,11 @@ class TranscodingV1 extends Worker
|
||||
$renditionPath = $renditionRootPath . $this->getRenditionName() . '-' . $query->getId() . '/';
|
||||
|
||||
try {
|
||||
$representation = (new Representation())->
|
||||
setKiloBitrate($profile->getAttribute('videoBitrate'))->
|
||||
setAudioKiloBitrate($profile->getAttribute('audioBitrate'))->
|
||||
setResize($profile->getAttribute('width'), $profile->getAttribute('height'));
|
||||
$representation = (new Representation())
|
||||
->setKiloBitrate($profile->getAttribute('videoBitrate'))
|
||||
->setAudioKiloBitrate($profile->getAttribute('audioBitrate'))
|
||||
->setResize($profile->getAttribute('width'), $profile->getAttribute('height'))
|
||||
;
|
||||
|
||||
$format = new Streaming\Format\X264();
|
||||
$format->on('progress', function ($video, $format, $percentage) use ($query, $collection) {
|
||||
@@ -360,6 +359,10 @@ class TranscodingV1 extends Worker
|
||||
*/
|
||||
private function transcode(string $stream, Media $video, StreamFormat $format, Representation $representation, array $subtitles): string | array
|
||||
{
|
||||
$video->filters()
|
||||
->framerate(new FFMpeg\Coordinate\FrameRate(24), 2)
|
||||
;
|
||||
|
||||
$additionalParams = [
|
||||
'-dn',
|
||||
'-sn',
|
||||
@@ -374,10 +377,10 @@ class TranscodingV1 extends Worker
|
||||
->setSegDuration($segmentSize)
|
||||
->addRepresentation($representation)
|
||||
->setAdditionalParams($additionalParams)
|
||||
->save($this->outPath);
|
||||
->save($this->outPath)
|
||||
;
|
||||
|
||||
return $this->getVideoStreamInfo($dash->metadata()->export(), $representation);
|
||||
;
|
||||
}
|
||||
|
||||
$hls = $video->hls();
|
||||
@@ -393,7 +396,8 @@ class TranscodingV1 extends Worker
|
||||
->setHlsAllowCache(false)
|
||||
->addRepresentation($representation)
|
||||
->setAdditionalParams($additionalParams)
|
||||
->save($this->outPath);
|
||||
->save($this->outPath)
|
||||
;
|
||||
|
||||
return $this->getVideoStreamInfo($hls->metadata()->export(), $representation);
|
||||
}
|
||||
|
||||
Generated
+9243
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user