1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
6 import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
8 const expect = chai.expect
10 describe('Test audio only video transcoding', function () {
11 let servers: PeerTubeServer[] = []
13 let webtorrentAudioFileUrl: string
14 let fragmentedAudioFileUrl: string
16 before(async function () {
19 const configOverride = {
40 servers = await createMultipleServers(2, configOverride)
42 // Get the access tokens
43 await setAccessTokensToServers(servers)
45 // Server 1 and server 2 follow each other
46 await doubleFollow(servers[0], servers[1])
49 it('Should upload a video and transcode it', async function () {
52 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
55 await waitJobs(servers)
57 for (const server of servers) {
58 const video = await server.videos.get({ id: videoUUID })
59 expect(video.streamingPlaylists).to.have.lengthOf(1)
61 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
62 expect(files).to.have.lengthOf(3)
63 expect(files[0].resolution.id).to.equal(720)
64 expect(files[1].resolution.id).to.equal(240)
65 expect(files[2].resolution.id).to.equal(0)
68 if (server.serverNumber === 1) {
69 webtorrentAudioFileUrl = video.files[2].fileUrl
70 fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
75 it('0p transcoded video should not have video', async function () {
77 servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl),
78 servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
81 for (const path of paths) {
82 const { audioStream } = await getAudioStream(path)
83 expect(audioStream['codec_name']).to.be.equal('aac')
84 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
86 const size = await getVideoStreamSize(path)
87 expect(size.height).to.equal(0)
88 expect(size.width).to.equal(0)
92 after(async function () {
93 await cleanupTests(servers)