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'
7 import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
9 const expect = chai.expect
11 describe('Test audio only video transcoding', function () {
12 let servers: PeerTubeServer[] = []
15 before(async function () {
18 const configOverride = {
39 servers = await createMultipleServers(2, configOverride)
41 // Get the access tokens
42 await setAccessTokensToServers(servers)
44 // Server 1 and server 2 follow each other
45 await doubleFollow(servers[0], servers[1])
48 it('Should upload a video and transcode it', async function () {
51 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
54 await waitJobs(servers)
56 for (const server of servers) {
57 const video = await server.videos.get({ id: videoUUID })
58 expect(video.streamingPlaylists).to.have.lengthOf(1)
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)
69 it('0p transcoded video should not have video', async function () {
71 servers[0].servers.buildDirectory(join('videos', videoUUID + '-0.mp4')),
72 servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
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)
80 const size = await getVideoStreamSize(path)
81 expect(size.height).to.equal(0)
82 expect(size.width).to.equal(0)
86 after(async function () {
87 await cleanupTests(servers)