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