aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/transcoding
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-05 10:36:19 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 09:18:07 +0200
commit84cae54e7a2595bea0c3ea106a4d111fd11a4ec6 (patch)
tree03fe73edf049ce60df6bbc34dcfb2031c07ea59c /server/tests/api/transcoding
parent7e0f50d6e0c7dc583d40e196c283eb20dc386ae6 (diff)
downloadPeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.gz
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.zst
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.zip
Add option to not transcode original resolution
Diffstat (limited to 'server/tests/api/transcoding')
-rw-r--r--server/tests/api/transcoding/transcoder.ts80
1 files changed, 78 insertions, 2 deletions
diff --git a/server/tests/api/transcoding/transcoder.ts b/server/tests/api/transcoding/transcoder.ts
index 245c4c012..48a20e1d5 100644
--- a/server/tests/api/transcoding/transcoder.ts
+++ b/server/tests/api/transcoding/transcoder.ts
@@ -7,11 +7,11 @@ import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
7import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared' 7import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared'
8import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' 8import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
9import { 9import {
10 getAudioStream,
11 buildFileMetadata, 10 buildFileMetadata,
11 getAudioStream,
12 getVideoStreamBitrate, 12 getVideoStreamBitrate,
13 getVideoStreamFPS,
14 getVideoStreamDimensionsInfo, 13 getVideoStreamDimensionsInfo,
14 getVideoStreamFPS,
15 hasAudioStream 15 hasAudioStream
16} from '@shared/extra-utils' 16} from '@shared/extra-utils'
17import { HttpStatusCode, VideoState } from '@shared/models' 17import { HttpStatusCode, VideoState } from '@shared/models'
@@ -727,6 +727,82 @@ describe('Test video transcoding', function () {
727 }) 727 })
728 }) 728 })
729 729
730 describe('Bounded transcoding', function () {
731
732 it('Should not generate an upper resolution than original file', async function () {
733 this.timeout(120_000)
734
735 await servers[0].config.updateExistingSubConfig({
736 newConfig: {
737 transcoding: {
738 enabled: true,
739 hls: { enabled: true },
740 webtorrent: { enabled: true },
741 resolutions: {
742 '0p': false,
743 '144p': false,
744 '240p': true,
745 '360p': false,
746 '480p': true,
747 '720p': false,
748 '1080p': false,
749 '1440p': false,
750 '2160p': false
751 },
752 alwaysTranscodeOriginalResolution: false
753 }
754 }
755 })
756
757 const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })
758 await waitJobs(servers)
759
760 const video = await servers[0].videos.get({ id: uuid })
761 const hlsFiles = video.streamingPlaylists[0].files
762
763 expect(video.files).to.have.lengthOf(2)
764 expect(hlsFiles).to.have.lengthOf(2)
765
766 // eslint-disable-next-line @typescript-eslint/require-array-sort-compare
767 const resolutions = getAllFiles(video).map(f => f.resolution.id).sort()
768 expect(resolutions).to.deep.equal([ 240, 240, 480, 480 ])
769 })
770
771 it('Should only keep the original resolution if all resolutions are disabled', async function () {
772 this.timeout(120_000)
773
774 await servers[0].config.updateExistingSubConfig({
775 newConfig: {
776 transcoding: {
777 resolutions: {
778 '0p': false,
779 '144p': false,
780 '240p': false,
781 '360p': false,
782 '480p': false,
783 '720p': false,
784 '1080p': false,
785 '1440p': false,
786 '2160p': false
787 }
788 }
789 }
790 })
791
792 const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' })
793 await waitJobs(servers)
794
795 const video = await servers[0].videos.get({ id: uuid })
796 const hlsFiles = video.streamingPlaylists[0].files
797
798 expect(video.files).to.have.lengthOf(1)
799 expect(hlsFiles).to.have.lengthOf(1)
800
801 expect(video.files[0].resolution.id).to.equal(720)
802 expect(hlsFiles[0].resolution.id).to.equal(720)
803 })
804 })
805
730 after(async function () { 806 after(async function () {
731 await cleanupTests(servers) 807 await cleanupTests(servers)
732 }) 808 })