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 = {
41 servers = await createMultipleServers(2, configOverride)
43 // Get the access tokens
44 await setAccessTokensToServers(servers)
46 // Server 1 and server 2 follow each other
47 await doubleFollow(servers[0], servers[1])
50 it('Should upload a video and transcode it', async function () {
53 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
56 await waitJobs(servers)
58 for (const server of servers) {
59 const video = await server.videos.get({ id: videoUUID })
60 expect(video.streamingPlaylists).to.have.lengthOf(1)
62 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
63 expect(files).to.have.lengthOf(3)
64 expect(files[0].resolution.id).to.equal(720)
65 expect(files[1].resolution.id).to.equal(240)
66 expect(files[2].resolution.id).to.equal(0)
69 if (server.serverNumber === 1) {
70 webtorrentAudioFileUrl = video.files[2].fileUrl
71 fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
76 it('0p transcoded video should not have video', async function () {
78 servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl),
79 servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
82 for (const path of paths) {
83 const { audioStream } = await getAudioStream(path)
84 expect(audioStream['codec_name']).to.be.equal('aac')
85 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
87 const size = await getVideoStreamSize(path)
88 expect(size.height).to.equal(0)
89 expect(size.width).to.equal(0)
93 after(async function () {
94 await cleanupTests(servers)