aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-03-10 14:39:40 +0100
committerGitHub <noreply@github.com>2020-03-10 14:39:40 +0100
commit8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4 (patch)
tree1f87041b2cd76222844960602cdc9f52fe206c7b /shared
parentedb868655e52f934a71141175cf9dc6cb4753e11 (diff)
downloadPeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.gz
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.tar.zst
PeerTube-8319d6ae72d4da6de51bd3d4b5c68040fc8dc3b4.zip
Add video file metadata to download modal, via ffprobe (#2411)
* Add video file metadata via ffprobe * Federate video file metadata * Add tests for file metadata generation * Complete tests for videoFile metadata federation * Lint migration and video-file for metadata * Objectify metadata from getter in ffmpeg-utils * Add metadataUrl to all videoFiles * Simplify metadata API middleware * Load playlist in videoFile when requesting metadata
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/videos/videos.ts9
-rw-r--r--shared/models/activitypub/objects/common-objects.ts11
-rw-r--r--shared/models/videos/video-file-metadata.ts18
-rw-r--r--shared/models/videos/video-file.model.ts3
4 files changed, 41 insertions, 0 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 39a06b0d7..0d36a38a2 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -95,6 +95,14 @@ function getVideo (url: string, id: number | string, expectedStatus = 200) {
95 .expect(expectedStatus) 95 .expect(expectedStatus)
96} 96}
97 97
98function getVideoFileMetadataUrl (url: string) {
99 return request(url)
100 .get('/')
101 .set('Accept', 'application/json')
102 .expect(200)
103 .expect('Content-Type', /json/)
104}
105
98function viewVideo (url: string, id: number | string, expectedStatus = 204, xForwardedFor?: string) { 106function viewVideo (url: string, id: number | string, expectedStatus = 204, xForwardedFor?: string) {
99 const path = '/api/v1/videos/' + id + '/views' 107 const path = '/api/v1/videos/' + id + '/views'
100 108
@@ -643,6 +651,7 @@ export {
643 getAccountVideos, 651 getAccountVideos,
644 getVideoChannelVideos, 652 getVideoChannelVideos,
645 getVideo, 653 getVideo,
654 getVideoFileMetadataUrl,
646 getVideoWithToken, 655 getVideoWithToken,
647 getVideosList, 656 getVideosList,
648 getVideosListPagination, 657 getVideosListPagination,
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts
index e94d05429..bb3ffe678 100644
--- a/shared/models/activitypub/objects/common-objects.ts
+++ b/shared/models/activitypub/objects/common-objects.ts
@@ -28,6 +28,15 @@ export type ActivityPlaylistSegmentHashesObject = {
28 href: string 28 href: string
29} 29}
30 30
31export type ActivityVideoFileMetadataObject = {
32 type: 'Link'
33 rel: [ 'metadata', any ]
34 mediaType: 'application/json'
35 height: number
36 href: string
37 fps: number
38}
39
31export type ActivityPlaylistInfohashesObject = { 40export type ActivityPlaylistInfohashesObject = {
32 type: 'Infohash' 41 type: 'Infohash'
33 name: string 42 name: string
@@ -80,6 +89,7 @@ export type ActivityTagObject =
80 | ActivityMentionObject 89 | ActivityMentionObject
81 | ActivityBitTorrentUrlObject 90 | ActivityBitTorrentUrlObject
82 | ActivityMagnetUrlObject 91 | ActivityMagnetUrlObject
92 | ActivityVideoFileMetadataObject
83 93
84export type ActivityUrlObject = 94export type ActivityUrlObject =
85 ActivityVideoUrlObject 95 ActivityVideoUrlObject
@@ -87,6 +97,7 @@ export type ActivityUrlObject =
87 | ActivityBitTorrentUrlObject 97 | ActivityBitTorrentUrlObject
88 | ActivityMagnetUrlObject 98 | ActivityMagnetUrlObject
89 | ActivityHtmlUrlObject 99 | ActivityHtmlUrlObject
100 | ActivityVideoFileMetadataObject
90 101
91export interface ActivityPubAttributedTo { 102export interface ActivityPubAttributedTo {
92 type: 'Group' | 'Person' 103 type: 'Group' | 'Person'
diff --git a/shared/models/videos/video-file-metadata.ts b/shared/models/videos/video-file-metadata.ts
new file mode 100644
index 000000000..15683cacf
--- /dev/null
+++ b/shared/models/videos/video-file-metadata.ts
@@ -0,0 +1,18 @@
1import { FfprobeData } from "fluent-ffmpeg"
2import { DeepOmit } from "@server/models/utils"
3
4export type VideoFileMetadataModel = DeepOmit<FfprobeData, 'filename'>
5
6export class VideoFileMetadata implements VideoFileMetadataModel {
7 streams: { [x: string]: any, [x: number]: any }[]
8 format: { [x: string]: any, [x: number]: any }
9 chapters: any[]
10
11 constructor (hash: Partial<VideoFileMetadataModel>) {
12 this.chapters = hash.chapters
13 this.format = hash.format
14 this.streams = hash.streams
15
16 delete this.format.filename
17 }
18}
diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/video-file.model.ts
index 04da0627e..6cc2d5aee 100644
--- a/shared/models/videos/video-file.model.ts
+++ b/shared/models/videos/video-file.model.ts
@@ -1,4 +1,5 @@
1import { VideoConstant, VideoResolution } from '@shared/models' 1import { VideoConstant, VideoResolution } from '@shared/models'
2import { FfprobeData } from 'fluent-ffmpeg'
2 3
3export interface VideoFile { 4export interface VideoFile {
4 magnetUri: string 5 magnetUri: string
@@ -9,4 +10,6 @@ export interface VideoFile {
9 fileUrl: string 10 fileUrl: string
10 fileDownloadUrl: string 11 fileDownloadUrl: string
11 fps: number 12 fps: number
13 metadata?: FfprobeData
14 metadataUrl?: string
12} 15}