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