aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/videos/video-transcoder.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts208
1 files changed, 94 insertions, 114 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index f16b22bae..b41c68283 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -2,11 +2,9 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfprobeData } from 'fluent-ffmpeg'
6import { omit } from 'lodash' 5import { omit } from 'lodash'
7import { join } from 'path' 6import { join } from 'path'
8import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 7import { HttpStatusCode } from '@shared/core-utils'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 8import {
11 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
12 cleanupTests, 10 cleanupTests,
@@ -14,19 +12,14 @@ import {
14 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
15 generateHighBitrateVideo, 13 generateHighBitrateVideo,
16 generateVideoWithFramerate, 14 generateVideoWithFramerate,
17 getMyVideos,
18 getVideo,
19 getVideoFileMetadataUrl,
20 getVideosList,
21 makeGetRequest, 15 makeGetRequest,
22 ServerInfo, 16 ServerInfo,
23 setAccessTokensToServers, 17 setAccessTokensToServers,
24 uploadVideo,
25 uploadVideoAndGetId,
26 waitJobs, 18 waitJobs,
27 webtorrentAdd 19 webtorrentAdd
28} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
29import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 21import { getMaxBitrate, VideoResolution, VideoState } from '@shared/models'
22import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
30import { 23import {
31 canDoQuickTranscode, 24 canDoQuickTranscode,
32 getAudioStream, 25 getAudioStream,
@@ -84,21 +77,20 @@ describe('Test video transcoding', function () {
84 it('Should not transcode video on server 1', async function () { 77 it('Should not transcode video on server 1', async function () {
85 this.timeout(60_000) 78 this.timeout(60_000)
86 79
87 const videoAttributes = { 80 const attributes = {
88 name: 'my super name for server 1', 81 name: 'my super name for server 1',
89 description: 'my super description for server 1', 82 description: 'my super description for server 1',
90 fixture: 'video_short.webm' 83 fixture: 'video_short.webm'
91 } 84 }
92 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) 85 await servers[0].videosCommand.upload({ attributes })
93 86
94 await waitJobs(servers) 87 await waitJobs(servers)
95 88
96 for (const server of servers) { 89 for (const server of servers) {
97 const res = await getVideosList(server.url) 90 const { data } = await server.videosCommand.list()
98 const video = res.body.data[0] 91 const video = data[0]
99 92
100 const res2 = await getVideo(server.url, video.id) 93 const videoDetails = await server.videosCommand.get({ id: video.id })
101 const videoDetails = res2.body
102 expect(videoDetails.files).to.have.lengthOf(1) 94 expect(videoDetails.files).to.have.lengthOf(1)
103 95
104 const magnetUri = videoDetails.files[0].magnetUri 96 const magnetUri = videoDetails.files[0].magnetUri
@@ -114,21 +106,20 @@ describe('Test video transcoding', function () {
114 it('Should transcode video on server 2', async function () { 106 it('Should transcode video on server 2', async function () {
115 this.timeout(120_000) 107 this.timeout(120_000)
116 108
117 const videoAttributes = { 109 const attributes = {
118 name: 'my super name for server 2', 110 name: 'my super name for server 2',
119 description: 'my super description for server 2', 111 description: 'my super description for server 2',
120 fixture: 'video_short.webm' 112 fixture: 'video_short.webm'
121 } 113 }
122 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 114 await servers[1].videosCommand.upload({ attributes })
123 115
124 await waitJobs(servers) 116 await waitJobs(servers)
125 117
126 for (const server of servers) { 118 for (const server of servers) {
127 const res = await getVideosList(server.url) 119 const { data } = await server.videosCommand.list()
128 120
129 const video = res.body.data.find(v => v.name === videoAttributes.name) 121 const video = data.find(v => v.name === attributes.name)
130 const res2 = await getVideo(server.url, video.id) 122 const videoDetails = await server.videosCommand.get({ id: video.id })
131 const videoDetails = res2.body
132 123
133 expect(videoDetails.files).to.have.lengthOf(4) 124 expect(videoDetails.files).to.have.lengthOf(4)
134 125
@@ -147,47 +138,50 @@ describe('Test video transcoding', function () {
147 138
148 { 139 {
149 // Upload the video, but wait transcoding 140 // Upload the video, but wait transcoding
150 const videoAttributes = { 141 const attributes = {
151 name: 'waiting video', 142 name: 'waiting video',
152 fixture: 'video_short1.webm', 143 fixture: 'video_short1.webm',
153 waitTranscoding: true 144 waitTranscoding: true
154 } 145 }
155 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 146 const { uuid } = await servers[1].videosCommand.upload({ attributes })
156 const videoId = resVideo.body.video.uuid 147 const videoId = uuid
157 148
158 // Should be in transcode state 149 // Should be in transcode state
159 const { body } = await getVideo(servers[1].url, videoId) 150 const body = await servers[1].videosCommand.get({ id: videoId })
160 expect(body.name).to.equal('waiting video') 151 expect(body.name).to.equal('waiting video')
161 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) 152 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
162 expect(body.state.label).to.equal('To transcode') 153 expect(body.state.label).to.equal('To transcode')
163 expect(body.waitTranscoding).to.be.true 154 expect(body.waitTranscoding).to.be.true
164 155
165 // Should have my video 156 {
166 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) 157 // Should have my video
167 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name) 158 const { data } = await servers[1].videosCommand.listMyVideos()
168 expect(videoToFindInMine).not.to.be.undefined 159 const videoToFindInMine = data.find(v => v.name === attributes.name)
169 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) 160 expect(videoToFindInMine).not.to.be.undefined
170 expect(videoToFindInMine.state.label).to.equal('To transcode') 161 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
171 expect(videoToFindInMine.waitTranscoding).to.be.true 162 expect(videoToFindInMine.state.label).to.equal('To transcode')
163 expect(videoToFindInMine.waitTranscoding).to.be.true
164 }
172 165
173 // Should not list this video 166 {
174 const resVideos = await getVideosList(servers[1].url) 167 // Should not list this video
175 const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name) 168 const { data } = await servers[1].videosCommand.list()
176 expect(videoToFindInList).to.be.undefined 169 const videoToFindInList = data.find(v => v.name === attributes.name)
170 expect(videoToFindInList).to.be.undefined
171 }
177 172
178 // Server 1 should not have the video yet 173 // Server 1 should not have the video yet
179 await getVideo(servers[0].url, videoId, HttpStatusCode.NOT_FOUND_404) 174 await servers[0].videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
180 } 175 }
181 176
182 await waitJobs(servers) 177 await waitJobs(servers)
183 178
184 for (const server of servers) { 179 for (const server of servers) {
185 const res = await getVideosList(server.url) 180 const { data } = await server.videosCommand.list()
186 const videoToFind = res.body.data.find(v => v.name === 'waiting video') 181 const videoToFind = data.find(v => v.name === 'waiting video')
187 expect(videoToFind).not.to.be.undefined 182 expect(videoToFind).not.to.be.undefined
188 183
189 const res2 = await getVideo(server.url, videoToFind.id) 184 const videoDetails = await server.videosCommand.get({ id: videoToFind.id })
190 const videoDetails: VideoDetails = res2.body
191 185
192 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) 186 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
193 expect(videoDetails.state.label).to.equal('Published') 187 expect(videoDetails.state.label).to.equal('Published')
@@ -208,22 +202,20 @@ describe('Test video transcoding', function () {
208 } 202 }
209 203
210 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { 204 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
211 const videoAttributes = { 205 const attributes = {
212 name: fixture, 206 name: fixture,
213 fixture 207 fixture
214 } 208 }
215 209
216 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 210 await servers[1].videosCommand.upload({ attributes })
217 211
218 await waitJobs(servers) 212 await waitJobs(servers)
219 213
220 for (const server of servers) { 214 for (const server of servers) {
221 const res = await getVideosList(server.url) 215 const { data } = await server.videosCommand.list()
222
223 const video = res.body.data.find(v => v.name === videoAttributes.name)
224 const res2 = await getVideo(server.url, video.id)
225 const videoDetails = res2.body
226 216
217 const video = data.find(v => v.name === attributes.name)
218 const videoDetails = await server.videosCommand.get({ id: video.id })
227 expect(videoDetails.files).to.have.lengthOf(4) 219 expect(videoDetails.files).to.have.lengthOf(4)
228 220
229 const magnetUri = videoDetails.files[0].magnetUri 221 const magnetUri = videoDetails.files[0].magnetUri
@@ -235,22 +227,20 @@ describe('Test video transcoding', function () {
235 it('Should transcode a 4k video', async function () { 227 it('Should transcode a 4k video', async function () {
236 this.timeout(200_000) 228 this.timeout(200_000)
237 229
238 const videoAttributes = { 230 const attributes = {
239 name: '4k video', 231 name: '4k video',
240 fixture: 'video_short_4k.mp4' 232 fixture: 'video_short_4k.mp4'
241 } 233 }
242 234
243 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 235 const { uuid } = await servers[1].videosCommand.upload({ attributes })
244 video4k = resUpload.body.video.uuid 236 video4k = uuid
245 237
246 await waitJobs(servers) 238 await waitJobs(servers)
247 239
248 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] 240 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
249 241
250 for (const server of servers) { 242 for (const server of servers) {
251 const res = await getVideo(server.url, video4k) 243 const videoDetails = await server.videosCommand.get({ id: video4k })
252 const videoDetails: VideoDetails = res.body
253
254 expect(videoDetails.files).to.have.lengthOf(resolutions.length) 244 expect(videoDetails.files).to.have.lengthOf(resolutions.length)
255 245
256 for (const r of resolutions) { 246 for (const r of resolutions) {
@@ -266,20 +256,19 @@ describe('Test video transcoding', function () {
266 it('Should transcode high bit rate mp3 to proper bit rate', async function () { 256 it('Should transcode high bit rate mp3 to proper bit rate', async function () {
267 this.timeout(60_000) 257 this.timeout(60_000)
268 258
269 const videoAttributes = { 259 const attributes = {
270 name: 'mp3_256k', 260 name: 'mp3_256k',
271 fixture: 'video_short_mp3_256k.mp4' 261 fixture: 'video_short_mp3_256k.mp4'
272 } 262 }
273 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 263 await servers[1].videosCommand.upload({ attributes })
274 264
275 await waitJobs(servers) 265 await waitJobs(servers)
276 266
277 for (const server of servers) { 267 for (const server of servers) {
278 const res = await getVideosList(server.url) 268 const { data } = await server.videosCommand.list()
279 269
280 const video = res.body.data.find(v => v.name === videoAttributes.name) 270 const video = data.find(v => v.name === attributes.name)
281 const res2 = await getVideo(server.url, video.id) 271 const videoDetails = await server.videosCommand.get({ id: video.id })
282 const videoDetails: VideoDetails = res2.body
283 272
284 expect(videoDetails.files).to.have.lengthOf(4) 273 expect(videoDetails.files).to.have.lengthOf(4)
285 274
@@ -298,20 +287,19 @@ describe('Test video transcoding', function () {
298 it('Should transcode video with no audio and have no audio itself', async function () { 287 it('Should transcode video with no audio and have no audio itself', async function () {
299 this.timeout(60_000) 288 this.timeout(60_000)
300 289
301 const videoAttributes = { 290 const attributes = {
302 name: 'no_audio', 291 name: 'no_audio',
303 fixture: 'video_short_no_audio.mp4' 292 fixture: 'video_short_no_audio.mp4'
304 } 293 }
305 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 294 await servers[1].videosCommand.upload({ attributes })
306 295
307 await waitJobs(servers) 296 await waitJobs(servers)
308 297
309 for (const server of servers) { 298 for (const server of servers) {
310 const res = await getVideosList(server.url) 299 const { data } = await server.videosCommand.list()
311 300
312 const video = res.body.data.find(v => v.name === videoAttributes.name) 301 const video = data.find(v => v.name === attributes.name)
313 const res2 = await getVideo(server.url, video.id) 302 const videoDetails = await server.videosCommand.get({ id: video.id })
314 const videoDetails: VideoDetails = res2.body
315 303
316 expect(videoDetails.files).to.have.lengthOf(4) 304 expect(videoDetails.files).to.have.lengthOf(4)
317 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 305 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
@@ -323,24 +311,23 @@ describe('Test video transcoding', function () {
323 it('Should leave the audio untouched, but properly transcode the video', async function () { 311 it('Should leave the audio untouched, but properly transcode the video', async function () {
324 this.timeout(60_000) 312 this.timeout(60_000)
325 313
326 const videoAttributes = { 314 const attributes = {
327 name: 'untouched_audio', 315 name: 'untouched_audio',
328 fixture: 'video_short.mp4' 316 fixture: 'video_short.mp4'
329 } 317 }
330 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 318 await servers[1].videosCommand.upload({ attributes })
331 319
332 await waitJobs(servers) 320 await waitJobs(servers)
333 321
334 for (const server of servers) { 322 for (const server of servers) {
335 const res = await getVideosList(server.url) 323 const { data } = await server.videosCommand.list()
336 324
337 const video = res.body.data.find(v => v.name === videoAttributes.name) 325 const video = data.find(v => v.name === attributes.name)
338 const res2 = await getVideo(server.url, video.id) 326 const videoDetails = await server.videosCommand.get({ id: video.id })
339 const videoDetails: VideoDetails = res2.body
340 327
341 expect(videoDetails.files).to.have.lengthOf(4) 328 expect(videoDetails.files).to.have.lengthOf(4)
342 329
343 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 330 const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
344 const fixtureVideoProbe = await getAudioStream(fixturePath) 331 const fixtureVideoProbe = await getAudioStream(fixturePath)
345 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 332 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
346 333
@@ -384,17 +371,16 @@ describe('Test video transcoding', function () {
384 it('Should merge an audio file with the preview file', async function () { 371 it('Should merge an audio file with the preview file', async function () {
385 this.timeout(60_000) 372 this.timeout(60_000)
386 373
387 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 374 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
388 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 375 await servers[1].videosCommand.upload({ attributes, mode })
389 376
390 await waitJobs(servers) 377 await waitJobs(servers)
391 378
392 for (const server of servers) { 379 for (const server of servers) {
393 const res = await getVideosList(server.url) 380 const { data } = await server.videosCommand.list()
394 381
395 const video = res.body.data.find(v => v.name === 'audio_with_preview') 382 const video = data.find(v => v.name === 'audio_with_preview')
396 const res2 = await getVideo(server.url, video.id) 383 const videoDetails = await server.videosCommand.get({ id: video.id })
397 const videoDetails: VideoDetails = res2.body
398 384
399 expect(videoDetails.files).to.have.lengthOf(1) 385 expect(videoDetails.files).to.have.lengthOf(1)
400 386
@@ -409,17 +395,16 @@ describe('Test video transcoding', function () {
409 it('Should upload an audio file and choose a default background image', async function () { 395 it('Should upload an audio file and choose a default background image', async function () {
410 this.timeout(60_000) 396 this.timeout(60_000)
411 397
412 const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' } 398 const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }
413 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 399 await servers[1].videosCommand.upload({ attributes, mode })
414 400
415 await waitJobs(servers) 401 await waitJobs(servers)
416 402
417 for (const server of servers) { 403 for (const server of servers) {
418 const res = await getVideosList(server.url) 404 const { data } = await server.videosCommand.list()
419 405
420 const video = res.body.data.find(v => v.name === 'audio_without_preview') 406 const video = data.find(v => v.name === 'audio_without_preview')
421 const res2 = await getVideo(server.url, video.id) 407 const videoDetails = await server.videosCommand.get({ id: video.id })
422 const videoDetails = res2.body
423 408
424 expect(videoDetails.files).to.have.lengthOf(1) 409 expect(videoDetails.files).to.have.lengthOf(1)
425 410
@@ -448,14 +433,13 @@ describe('Test video transcoding', function () {
448 } 433 }
449 }) 434 })
450 435
451 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 436 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
452 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode) 437 const { id } = await servers[1].videosCommand.upload({ attributes, mode })
453 438
454 await waitJobs(servers) 439 await waitJobs(servers)
455 440
456 for (const server of servers) { 441 for (const server of servers) {
457 const res2 = await getVideo(server.url, resVideo.body.video.id) 442 const videoDetails = await server.videosCommand.get({ id })
458 const videoDetails: VideoDetails = res2.body
459 443
460 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) { 444 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
461 expect(files).to.have.lengthOf(2) 445 expect(files).to.have.lengthOf(2)
@@ -481,21 +465,20 @@ describe('Test video transcoding', function () {
481 it('Should transcode a 60 FPS video', async function () { 465 it('Should transcode a 60 FPS video', async function () {
482 this.timeout(60_000) 466 this.timeout(60_000)
483 467
484 const videoAttributes = { 468 const attributes = {
485 name: 'my super 30fps name for server 2', 469 name: 'my super 30fps name for server 2',
486 description: 'my super 30fps description for server 2', 470 description: 'my super 30fps description for server 2',
487 fixture: '60fps_720p_small.mp4' 471 fixture: '60fps_720p_small.mp4'
488 } 472 }
489 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 473 await servers[1].videosCommand.upload({ attributes })
490 474
491 await waitJobs(servers) 475 await waitJobs(servers)
492 476
493 for (const server of servers) { 477 for (const server of servers) {
494 const res = await getVideosList(server.url) 478 const { data } = await server.videosCommand.list()
495 479
496 const video = res.body.data.find(v => v.name === videoAttributes.name) 480 const video = data.find(v => v.name === attributes.name)
497 const res2 = await getVideo(server.url, video.id) 481 const videoDetails = await server.videosCommand.get({ id: video.id })
498 const videoDetails: VideoDetails = res2.body
499 482
500 expect(videoDetails.files).to.have.lengthOf(4) 483 expect(videoDetails.files).to.have.lengthOf(4)
501 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) 484 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
@@ -529,20 +512,20 @@ describe('Test video transcoding', function () {
529 expect(fps).to.be.equal(59) 512 expect(fps).to.be.equal(59)
530 } 513 }
531 514
532 const videoAttributes = { 515 const attributes = {
533 name: '59fps video', 516 name: '59fps video',
534 description: '59fps video', 517 description: '59fps video',
535 fixture: tempFixturePath 518 fixture: tempFixturePath
536 } 519 }
537 520
538 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 521 await servers[1].videosCommand.upload({ attributes })
539 522
540 await waitJobs(servers) 523 await waitJobs(servers)
541 524
542 for (const server of servers) { 525 for (const server of servers) {
543 const res = await getVideosList(server.url) 526 const { data } = await server.videosCommand.list()
544 527
545 const video = res.body.data.find(v => v.name === videoAttributes.name) 528 const video = data.find(v => v.name === attributes.name)
546 529
547 { 530 {
548 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 531 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
@@ -572,20 +555,20 @@ describe('Test video transcoding', function () {
572 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) 555 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
573 } 556 }
574 557
575 const videoAttributes = { 558 const attributes = {
576 name: 'high bitrate video', 559 name: 'high bitrate video',
577 description: 'high bitrate video', 560 description: 'high bitrate video',
578 fixture: tempFixturePath 561 fixture: tempFixturePath
579 } 562 }
580 563
581 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 564 await servers[1].videosCommand.upload({ attributes })
582 565
583 await waitJobs(servers) 566 await waitJobs(servers)
584 567
585 for (const server of servers) { 568 for (const server of servers) {
586 const res = await getVideosList(server.url) 569 const { data } = await server.videosCommand.list()
587 570
588 const video = res.body.data.find(v => v.name === videoAttributes.name) 571 const video = data.find(v => v.name === attributes.name)
589 572
590 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 573 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
591 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 574 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
@@ -621,19 +604,18 @@ describe('Test video transcoding', function () {
621 } 604 }
622 await servers[1].configCommand.updateCustomSubConfig({ newConfig }) 605 await servers[1].configCommand.updateCustomSubConfig({ newConfig })
623 606
624 const videoAttributes = { 607 const attributes = {
625 name: 'low bitrate', 608 name: 'low bitrate',
626 fixture: 'low-bitrate.mp4' 609 fixture: 'low-bitrate.mp4'
627 } 610 }
628 611
629 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 612 const { uuid } = await servers[1].videosCommand.upload({ attributes })
630 const videoUUID = resUpload.body.video.uuid
631 613
632 await waitJobs(servers) 614 await waitJobs(servers)
633 615
634 const resolutions = [ 240, 360, 480, 720, 1080 ] 616 const resolutions = [ 240, 360, 480, 720, 1080 ]
635 for (const r of resolutions) { 617 for (const r of resolutions) {
636 const path = `videos/${videoUUID}-${r}.mp4` 618 const path = `videos/${uuid}-${r}.mp4`
637 const size = await servers[1].serversCommand.getServerFileSize(path) 619 const size = await servers[1].serversCommand.getServerFileSize(path)
638 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 620 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
639 } 621 }
@@ -645,7 +627,7 @@ describe('Test video transcoding', function () {
645 it('Should provide valid ffprobe data', async function () { 627 it('Should provide valid ffprobe data', async function () {
646 this.timeout(160_000) 628 this.timeout(160_000)
647 629
648 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid 630 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'ffprobe data' })).uuid
649 await waitJobs(servers) 631 await waitJobs(servers)
650 632
651 { 633 {
@@ -679,8 +661,7 @@ describe('Test video transcoding', function () {
679 } 661 }
680 662
681 for (const server of servers) { 663 for (const server of servers) {
682 const res2 = await getVideo(server.url, videoUUID) 664 const videoDetails = await server.videosCommand.get({ id: videoUUID })
683 const videoDetails: VideoDetails = res2.body
684 665
685 const videoFiles = videoDetails.files 666 const videoFiles = videoDetails.files
686 .concat(videoDetails.streamingPlaylists[0].files) 667 .concat(videoDetails.streamingPlaylists[0].files)
@@ -692,8 +673,7 @@ describe('Test video transcoding', function () {
692 expect(file.metadataUrl).to.contain(servers[1].url) 673 expect(file.metadataUrl).to.contain(servers[1].url)
693 expect(file.metadataUrl).to.contain(videoUUID) 674 expect(file.metadataUrl).to.contain(videoUUID)
694 675
695 const res3 = await getVideoFileMetadataUrl(file.metadataUrl) 676 const metadata = await server.videosCommand.getFileMetadata({ url: file.metadataUrl })
696 const metadata: FfprobeData = res3.body
697 expect(metadata).to.have.nested.property('format.size') 677 expect(metadata).to.have.nested.property('format.size')
698 } 678 }
699 } 679 }