]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
3a149e9f | 2 | |
86347717 | 3 | import { expect } from 'chai' |
c729caf6 | 4 | import { getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg' |
c55e3d72 C |
5 | import { |
6 | cleanupTests, | |
7 | createMultipleServers, | |
8 | doubleFollow, | |
9 | PeerTubeServer, | |
10 | setAccessTokensToServers, | |
11 | waitJobs | |
12 | } from '@shared/server-commands' | |
3a149e9f | 13 | |
3a149e9f | 14 | describe('Test audio only video transcoding', function () { |
254d3579 | 15 | let servers: PeerTubeServer[] = [] |
3a149e9f | 16 | let videoUUID: string |
83903cb6 C |
17 | let webtorrentAudioFileUrl: string |
18 | let fragmentedAudioFileUrl: string | |
3a149e9f C |
19 | |
20 | before(async function () { | |
21 | this.timeout(120000) | |
22 | ||
23 | const configOverride = { | |
24 | transcoding: { | |
25 | enabled: true, | |
26 | resolutions: { | |
27 | '0p': true, | |
8dd754c7 | 28 | '144p': false, |
3a149e9f C |
29 | '240p': true, |
30 | '360p': false, | |
31 | '480p': false, | |
32 | '720p': false, | |
33 | '1080p': false, | |
b7085c71 | 34 | '1440p': false, |
3a149e9f C |
35 | '2160p': false |
36 | }, | |
37 | hls: { | |
38 | enabled: true | |
39 | }, | |
40 | webtorrent: { | |
41 | enabled: true | |
42 | } | |
43 | } | |
44 | } | |
254d3579 | 45 | servers = await createMultipleServers(2, configOverride) |
3a149e9f C |
46 | |
47 | // Get the access tokens | |
48 | await setAccessTokensToServers(servers) | |
49 | ||
50 | // Server 1 and server 2 follow each other | |
51 | await doubleFollow(servers[0], servers[1]) | |
52 | }) | |
53 | ||
54 | it('Should upload a video and transcode it', async function () { | |
55 | this.timeout(120000) | |
56 | ||
89d241a7 | 57 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } }) |
d23dd9fb | 58 | videoUUID = uuid |
3a149e9f C |
59 | |
60 | await waitJobs(servers) | |
61 | ||
62 | for (const server of servers) { | |
89d241a7 | 63 | const video = await server.videos.get({ id: videoUUID }) |
3a149e9f C |
64 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
65 | ||
66 | for (const files of [ video.files, video.streamingPlaylists[0].files ]) { | |
67 | expect(files).to.have.lengthOf(3) | |
68 | expect(files[0].resolution.id).to.equal(720) | |
69 | expect(files[1].resolution.id).to.equal(240) | |
70 | expect(files[2].resolution.id).to.equal(0) | |
71 | } | |
83903cb6 C |
72 | |
73 | if (server.serverNumber === 1) { | |
74 | webtorrentAudioFileUrl = video.files[2].fileUrl | |
75 | fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl | |
76 | } | |
3a149e9f C |
77 | } |
78 | }) | |
79 | ||
80 | it('0p transcoded video should not have video', async function () { | |
81 | const paths = [ | |
83903cb6 C |
82 | servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl), |
83 | servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl) | |
3a149e9f C |
84 | ] |
85 | ||
86 | for (const path of paths) { | |
daf6e480 | 87 | const { audioStream } = await getAudioStream(path) |
a1587156 C |
88 | expect(audioStream['codec_name']).to.be.equal('aac') |
89 | expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) | |
3a149e9f | 90 | |
c729caf6 | 91 | const size = await getVideoStreamDimensionsInfo(path) |
a742347d C |
92 | |
93 | expect(size.height).to.equal(0) | |
94 | expect(size.width).to.equal(0) | |
95 | expect(size.isPortraitMode).to.be.false | |
96 | expect(size.ratio).to.equal(0) | |
97 | expect(size.resolution).to.equal(0) | |
3a149e9f C |
98 | } |
99 | }) | |
100 | ||
101 | after(async function () { | |
102 | await cleanupTests(servers) | |
103 | }) | |
104 | }) |