aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts60
1 files changed, 39 insertions, 21 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index e4892bb24..2a09e95bf 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -3,7 +3,6 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path'
7import { 6import {
8 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
9 cleanupTests, 8 cleanupTests,
@@ -11,6 +10,7 @@ import {
11 doubleFollow, 10 doubleFollow,
12 generateHighBitrateVideo, 11 generateHighBitrateVideo,
13 generateVideoWithFramerate, 12 generateVideoWithFramerate,
13 getFileSize,
14 makeGetRequest, 14 makeGetRequest,
15 PeerTubeServer, 15 PeerTubeServer,
16 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -271,7 +271,8 @@ describe('Test video transcoding', function () {
271 271
272 expect(videoDetails.files).to.have.lengthOf(4) 272 expect(videoDetails.files).to.have.lengthOf(4)
273 273
274 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) 274 const file = videoDetails.files.find(f => f.resolution.id === 240)
275 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
275 const probe = await getAudioStream(path) 276 const probe = await getAudioStream(path)
276 277
277 if (probe.audioStream) { 278 if (probe.audioStream) {
@@ -300,8 +301,9 @@ describe('Test video transcoding', function () {
300 const video = data.find(v => v.name === attributes.name) 301 const video = data.find(v => v.name === attributes.name)
301 const videoDetails = await server.videos.get({ id: video.id }) 302 const videoDetails = await server.videos.get({ id: video.id })
302 303
303 expect(videoDetails.files).to.have.lengthOf(4) 304 const file = videoDetails.files.find(f => f.resolution.id === 240)
304 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) 305 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
306
305 const probe = await getAudioStream(path) 307 const probe = await getAudioStream(path)
306 expect(probe).to.not.have.property('audioStream') 308 expect(probe).to.not.have.property('audioStream')
307 } 309 }
@@ -328,7 +330,9 @@ describe('Test video transcoding', function () {
328 330
329 const fixturePath = buildAbsoluteFixturePath(attributes.fixture) 331 const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
330 const fixtureVideoProbe = await getAudioStream(fixturePath) 332 const fixtureVideoProbe = await getAudioStream(fixturePath)
331 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) 333
334 const file = videoDetails.files.find(f => f.resolution.id === 240)
335 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
332 336
333 const videoProbe = await getAudioStream(path) 337 const videoProbe = await getAudioStream(path)
334 338
@@ -485,14 +489,16 @@ describe('Test video transcoding', function () {
485 expect(videoDetails.files[2].fps).to.be.below(31) 489 expect(videoDetails.files[2].fps).to.be.below(31)
486 expect(videoDetails.files[3].fps).to.be.below(31) 490 expect(videoDetails.files[3].fps).to.be.below(31)
487 491
488 for (const resolution of [ '240', '360', '480' ]) { 492 for (const resolution of [ 240, 360, 480 ]) {
489 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 493 const file = videoDetails.files.find(f => f.resolution.id === resolution)
494 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
490 const fps = await getVideoFileFPS(path) 495 const fps = await getVideoFileFPS(path)
491 496
492 expect(fps).to.be.below(31) 497 expect(fps).to.be.below(31)
493 } 498 }
494 499
495 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4')) 500 const file = videoDetails.files.find(f => f.resolution.id === 720)
501 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
496 const fps = await getVideoFileFPS(path) 502 const fps = await getVideoFileFPS(path)
497 503
498 expect(fps).to.be.above(58).and.below(62) 504 expect(fps).to.be.above(58).and.below(62)
@@ -524,16 +530,19 @@ describe('Test video transcoding', function () {
524 for (const server of servers) { 530 for (const server of servers) {
525 const { data } = await server.videos.list() 531 const { data } = await server.videos.list()
526 532
527 const video = data.find(v => v.name === attributes.name) 533 const { id } = data.find(v => v.name === attributes.name)
534 const video = await server.videos.get({ id })
528 535
529 { 536 {
530 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) 537 const file = video.files.find(f => f.resolution.id === 240)
538 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
531 const fps = await getVideoFileFPS(path) 539 const fps = await getVideoFileFPS(path)
532 expect(fps).to.be.equal(25) 540 expect(fps).to.be.equal(25)
533 } 541 }
534 542
535 { 543 {
536 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4')) 544 const file = video.files.find(f => f.resolution.id === 720)
545 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
537 const fps = await getVideoFileFPS(path) 546 const fps = await getVideoFileFPS(path)
538 expect(fps).to.be.equal(59) 547 expect(fps).to.be.equal(59)
539 } 548 }
@@ -542,6 +551,7 @@ describe('Test video transcoding', function () {
542 }) 551 })
543 552
544 describe('Bitrate control', function () { 553 describe('Bitrate control', function () {
554
545 it('Should respect maximum bitrate values', async function () { 555 it('Should respect maximum bitrate values', async function () {
546 this.timeout(160_000) 556 this.timeout(160_000)
547 557
@@ -567,17 +577,19 @@ describe('Test video transcoding', function () {
567 for (const server of servers) { 577 for (const server of servers) {
568 const { data } = await server.videos.list() 578 const { data } = await server.videos.list()
569 579
570 const video = data.find(v => v.name === attributes.name) 580 const { id } = data.find(v => v.name === attributes.name)
581 const video = await server.videos.get({ id })
571 582
572 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 583 for (const resolution of [ 240, 360, 480, 720, 1080 ]) {
573 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 584 const file = video.files.find(f => f.resolution.id === resolution)
585 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
574 586
575 const bitrate = await getVideoFileBitrate(path) 587 const bitrate = await getVideoFileBitrate(path)
576 const fps = await getVideoFileFPS(path) 588 const fps = await getVideoFileFPS(path)
577 const resolution2 = await getVideoFileResolution(path) 589 const { videoFileResolution } = await getVideoFileResolution(path)
578 590
579 expect(resolution2.videoFileResolution.toString()).to.equal(resolution) 591 expect(videoFileResolution).to.equal(resolution)
580 expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) 592 expect(bitrate).to.be.below(getMaxBitrate(videoFileResolution, fps, VIDEO_TRANSCODING_FPS))
581 } 593 }
582 } 594 }
583 }) 595 })
@@ -608,14 +620,18 @@ describe('Test video transcoding', function () {
608 fixture: 'low-bitrate.mp4' 620 fixture: 'low-bitrate.mp4'
609 } 621 }
610 622
611 const { uuid } = await servers[1].videos.upload({ attributes }) 623 const { id } = await servers[1].videos.upload({ attributes })
612 624
613 await waitJobs(servers) 625 await waitJobs(servers)
614 626
627 const video = await servers[1].videos.get({ id })
628
615 const resolutions = [ 240, 360, 480, 720, 1080 ] 629 const resolutions = [ 240, 360, 480, 720, 1080 ]
616 for (const r of resolutions) { 630 for (const r of resolutions) {
617 const path = `videos/${uuid}-${r}.mp4` 631 const file = video.files.find(f => f.resolution.id === r)
618 const size = await servers[1].servers.getServerFileSize(path) 632
633 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
634 const size = await getFileSize(path)
619 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 635 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
620 } 636 }
621 }) 637 })
@@ -630,7 +646,9 @@ describe('Test video transcoding', function () {
630 await waitJobs(servers) 646 await waitJobs(servers)
631 647
632 { 648 {
633 const path = servers[1].servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) 649 const video = await servers[1].videos.get({ id: videoUUID })
650 const file = video.files.find(f => f.resolution.id === 240)
651 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
634 const metadata = await getMetadataFromFile(path) 652 const metadata = await getMetadataFromFile(path)
635 653
636 // expected format properties 654 // expected format properties