]>
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 { join } from 'path' | |
6 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' | |
7 | import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | |
8 | ||
9 | const expect = chai.expect | |
10 | ||
11 | describe('Test audio only video transcoding', function () { | |
12 | let servers: PeerTubeServer[] = [] | |
13 | let videoUUID: string | |
14 | ||
15 | before(async function () { | |
16 | this.timeout(120000) | |
17 | ||
18 | const configOverride = { | |
19 | transcoding: { | |
20 | enabled: true, | |
21 | resolutions: { | |
22 | '0p': true, | |
23 | '240p': true, | |
24 | '360p': false, | |
25 | '480p': false, | |
26 | '720p': false, | |
27 | '1080p': false, | |
28 | '1440p': false, | |
29 | '2160p': false | |
30 | }, | |
31 | hls: { | |
32 | enabled: true | |
33 | }, | |
34 | webtorrent: { | |
35 | enabled: true | |
36 | } | |
37 | } | |
38 | } | |
39 | servers = await createMultipleServers(2, configOverride) | |
40 | ||
41 | // Get the access tokens | |
42 | await setAccessTokensToServers(servers) | |
43 | ||
44 | // Server 1 and server 2 follow each other | |
45 | await doubleFollow(servers[0], servers[1]) | |
46 | }) | |
47 | ||
48 | it('Should upload a video and transcode it', async function () { | |
49 | this.timeout(120000) | |
50 | ||
51 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } }) | |
52 | videoUUID = uuid | |
53 | ||
54 | await waitJobs(servers) | |
55 | ||
56 | for (const server of servers) { | |
57 | const video = await server.videos.get({ id: videoUUID }) | |
58 | expect(video.streamingPlaylists).to.have.lengthOf(1) | |
59 | ||
60 | for (const files of [ video.files, video.streamingPlaylists[0].files ]) { | |
61 | expect(files).to.have.lengthOf(3) | |
62 | expect(files[0].resolution.id).to.equal(720) | |
63 | expect(files[1].resolution.id).to.equal(240) | |
64 | expect(files[2].resolution.id).to.equal(0) | |
65 | } | |
66 | } | |
67 | }) | |
68 | ||
69 | it('0p transcoded video should not have video', async function () { | |
70 | const paths = [ | |
71 | servers[0].servers.buildDirectory(join('videos', videoUUID + '-0.mp4')), | |
72 | servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) | |
73 | ] | |
74 | ||
75 | for (const path of paths) { | |
76 | const { audioStream } = await getAudioStream(path) | |
77 | expect(audioStream['codec_name']).to.be.equal('aac') | |
78 | expect(audioStream['bit_rate']).to.be.at.most(384 * 8000) | |
79 | ||
80 | const size = await getVideoStreamSize(path) | |
81 | expect(size.height).to.equal(0) | |
82 | expect(size.width).to.equal(0) | |
83 | } | |
84 | }) | |
85 | ||
86 | after(async function () { | |
87 | await cleanupTests(servers) | |
88 | }) | |
89 | }) |