1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { join } from 'path'
6 import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
11 flushAndRunMultipleServers,
14 setAccessTokensToServers,
17 } from '../../../../shared/extra-utils'
18 import { VideoDetails } from '../../../../shared/models/videos'
20 const expect = chai.expect
22 describe('Test audio only video transcoding', function () {
23 let servers: ServerInfo[] = []
26 before(async function () {
29 const configOverride = {
49 servers = await flushAndRunMultipleServers(2, configOverride)
51 // Get the access tokens
52 await setAccessTokensToServers(servers)
54 // Server 1 and server 2 follow each other
55 await doubleFollow(servers[0], servers[1])
58 it('Should upload a video and transcode it', async function () {
61 const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only' })
62 videoUUID = resUpload.body.video.uuid
64 await waitJobs(servers)
66 for (const server of servers) {
67 const res = await getVideo(server.url, videoUUID)
68 const video: VideoDetails = res.body
70 expect(video.streamingPlaylists).to.have.lengthOf(1)
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)
81 it('0p transcoded video should not have video', async function () {
83 buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')),
84 buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
87 for (const path of paths) {
88 const { audioStream } = await getAudioStream(path)
89 expect(audioStream['codec_name']).to.be.equal('aac')
90 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
92 const size = await getVideoStreamSize(path)
93 expect(size.height).to.equal(0)
94 expect(size.width).to.equal(0)
98 after(async function () {
99 await cleanupTests(servers)