diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-05 10:36:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:18:07 +0200 |
commit | 84cae54e7a2595bea0c3ea106a4d111fd11a4ec6 (patch) | |
tree | 03fe73edf049ce60df6bbc34dcfb2031c07ea59c /server/tests/api/live/live.ts | |
parent | 7e0f50d6e0c7dc583d40e196c283eb20dc386ae6 (diff) | |
download | PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.gz PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.zst PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.zip |
Add option to not transcode original resolution
Diffstat (limited to 'server/tests/api/live/live.ts')
-rw-r--r-- | server/tests/api/live/live.ts | 73 |
1 files changed, 68 insertions, 5 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 2d47c131b..f6ad5c82e 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' | 6 | import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' |
7 | import { checkLiveCleanup, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared' | 7 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, getAllFiles, testImage } from '@server/tests/shared' |
8 | import { wait } from '@shared/core-utils' | 8 | import { wait } from '@shared/core-utils' |
9 | import { | 9 | import { |
10 | HttpStatusCode, | 10 | HttpStatusCode, |
@@ -468,7 +468,7 @@ describe('Test live', function () { | |||
468 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 468 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
469 | await waitJobs(servers) | 469 | await waitJobs(servers) |
470 | 470 | ||
471 | await testVideoResolutions(liveVideoId, resolutions) | 471 | await testVideoResolutions(liveVideoId, resolutions.concat([ 720 ])) |
472 | 472 | ||
473 | await stopFfmpeg(ffmpegCommand) | 473 | await stopFfmpeg(ffmpegCommand) |
474 | }) | 474 | }) |
@@ -580,10 +580,73 @@ describe('Test live', function () { | |||
580 | } | 580 | } |
581 | }) | 581 | }) |
582 | 582 | ||
583 | it('Should correctly have cleaned up the live files', async function () { | 583 | it('Should not generate an upper resolution than original file', async function () { |
584 | this.timeout(30000) | 584 | this.timeout(400_000) |
585 | |||
586 | const resolutions = [ 240, 480 ] | ||
587 | await updateConf(resolutions) | ||
588 | |||
589 | await servers[0].config.updateExistingSubConfig({ | ||
590 | newConfig: { | ||
591 | live: { | ||
592 | transcoding: { | ||
593 | alwaysTranscodeOriginalResolution: false | ||
594 | } | ||
595 | } | ||
596 | } | ||
597 | }) | ||
598 | |||
599 | liveVideoId = await createLiveWrapper(true) | ||
600 | |||
601 | const ffmpegCommand = await commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | ||
602 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | ||
603 | await waitJobs(servers) | ||
604 | |||
605 | await testVideoResolutions(liveVideoId, resolutions) | ||
606 | |||
607 | await stopFfmpeg(ffmpegCommand) | ||
608 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) | ||
609 | |||
610 | await waitJobs(servers) | ||
611 | |||
612 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | ||
613 | |||
614 | const video = await servers[0].videos.get({ id: liveVideoId }) | ||
615 | const hlsFiles = video.streamingPlaylists[0].files | ||
616 | |||
617 | expect(video.files).to.have.lengthOf(0) | ||
618 | expect(hlsFiles).to.have.lengthOf(resolutions.length) | ||
619 | |||
620 | // eslint-disable-next-line @typescript-eslint/require-array-sort-compare | ||
621 | expect(getAllFiles(video).map(f => f.resolution.id).sort()).to.deep.equal(resolutions) | ||
622 | }) | ||
623 | |||
624 | it('Should only keep the original resolution if all resolutions are disabled', async function () { | ||
625 | this.timeout(400_000) | ||
626 | |||
627 | await updateConf([]) | ||
628 | liveVideoId = await createLiveWrapper(true) | ||
629 | |||
630 | const ffmpegCommand = await commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | ||
631 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | ||
632 | await waitJobs(servers) | ||
633 | |||
634 | await testVideoResolutions(liveVideoId, [ 720 ]) | ||
635 | |||
636 | await stopFfmpeg(ffmpegCommand) | ||
637 | await commands[0].waitUntilEnded({ videoId: liveVideoId }) | ||
638 | |||
639 | await waitJobs(servers) | ||
640 | |||
641 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | ||
642 | |||
643 | const video = await servers[0].videos.get({ id: liveVideoId }) | ||
644 | const hlsFiles = video.streamingPlaylists[0].files | ||
645 | |||
646 | expect(video.files).to.have.lengthOf(0) | ||
647 | expect(hlsFiles).to.have.lengthOf(1) | ||
585 | 648 | ||
586 | await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ]) | 649 | expect(hlsFiles[0].resolution.id).to.equal(720) |
587 | }) | 650 | }) |
588 | }) | 651 | }) |
589 | 652 | ||