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