]>
Commit | Line | Data |
---|---|---|
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' | |
6 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | |
7 | ||
8 | const expect = chai.expect | |
9 | ||
10 | describe('Test audio only video transcoding', function () { | |
11 | let servers: PeerTubeServer[] = [] | |
12 | let videoUUID: string | |
13 | let webtorrentAudioFileUrl: string | |
14 | let fragmentedAudioFileUrl: string | |
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, | |
29 | '1440p': false, | |
30 | '2160p': false | |
31 | }, | |
32 | hls: { | |
33 | enabled: true | |
34 | }, | |
35 | webtorrent: { | |
36 | enabled: true | |
37 | } | |
38 | } | |
39 | } | |
40 | servers = await createMultipleServers(2, configOverride) | |
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 | ||
52 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } }) | |
53 | videoUUID = uuid | |
54 | ||
55 | await waitJobs(servers) | |
56 | ||
57 | for (const server of servers) { | |
58 | const video = await server.videos.get({ id: videoUUID }) | |
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 | } | |
67 | ||
68 | if (server.serverNumber === 1) { | |
69 | webtorrentAudioFileUrl = video.files[2].fileUrl | |
70 | fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl | |
71 | } | |
72 | } | |
73 | }) | |
74 | ||
75 | it('0p transcoded video should not have video', async function () { | |
76 | const paths = [ | |
77 | servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl), | |
78 | servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl) | |
79 | ] | |
80 | ||
81 | for (const path of paths) { | |
82 | const { audioStream } = await getAudioStream(path) | |
83 | expect(audioStream['codec_name']).to.be.equal('aac') | |
84 | expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) | |
85 | ||
86 | const size = await getVideoStreamSize(path) | |
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 | }) |