1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import * as chai from 'chai'
4 import { getAudioStream, getVideoStreamDimensionsInfo } from '@server/helpers/ffmpeg'
10 setAccessTokensToServers,
12 } from '@shared/server-commands'
14 const expect = chai.expect
16 describe('Test audio only video transcoding', function () {
17 let servers: PeerTubeServer[] = []
19 let webtorrentAudioFileUrl: string
20 let fragmentedAudioFileUrl: string
22 before(async function () {
25 const configOverride = {
47 servers = await createMultipleServers(2, configOverride)
49 // Get the access tokens
50 await setAccessTokensToServers(servers)
52 // Server 1 and server 2 follow each other
53 await doubleFollow(servers[0], servers[1])
56 it('Should upload a video and transcode it', async function () {
59 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
62 await waitJobs(servers)
64 for (const server of servers) {
65 const video = await server.videos.get({ id: videoUUID })
66 expect(video.streamingPlaylists).to.have.lengthOf(1)
68 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
69 expect(files).to.have.lengthOf(3)
70 expect(files[0].resolution.id).to.equal(720)
71 expect(files[1].resolution.id).to.equal(240)
72 expect(files[2].resolution.id).to.equal(0)
75 if (server.serverNumber === 1) {
76 webtorrentAudioFileUrl = video.files[2].fileUrl
77 fragmentedAudioFileUrl = video.streamingPlaylists[0].files[2].fileUrl
82 it('0p transcoded video should not have video', async function () {
84 servers[0].servers.buildWebTorrentFilePath(webtorrentAudioFileUrl),
85 servers[0].servers.buildFragmentedFilePath(videoUUID, fragmentedAudioFileUrl)
88 for (const path of paths) {
89 const { audioStream } = await getAudioStream(path)
90 expect(audioStream['codec_name']).to.be.equal('aac')
91 expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
93 const size = await getVideoStreamDimensionsInfo(path)
94 expect(size).to.not.exist
98 after(async function () {
99 await cleanupTests(servers)