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