1 /* tslint:disable:no-unused-expression */
3 import * as chai from 'chai'
11 flushAndRunMultipleServers,
13 getVideo, makeGetRequest, makeRawRequest,
16 setAccessTokensToServers, updateCustomSubConfig,
19 waitJobs, webtorrentAdd
20 } from '../../../../shared/extra-utils'
21 import { VideoDetails } from '../../../../shared/models/videos'
22 import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
23 import { join } from 'path'
24 import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
25 import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution, audio, getVideoStreamSize } from '@server/helpers/ffmpeg-utils'
27 const expect = chai.expect
29 describe('Test audio only video transcoding', function () {
30 let servers: ServerInfo[] = []
33 before(async function () {
36 const configOverride = {
56 servers = await flushAndRunMultipleServers(2, configOverride)
58 // Get the access tokens
59 await setAccessTokensToServers(servers)
61 // Server 1 and server 2 follow each other
62 await doubleFollow(servers[0], servers[1])
65 it('Should upload a video and transcode it', async function () {
68 const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only' })
69 videoUUID = resUpload.body.video.uuid
71 await waitJobs(servers)
73 for (const server of servers) {
74 const res = await getVideo(server.url, videoUUID)
75 const video: VideoDetails = res.body
77 expect(video.streamingPlaylists).to.have.lengthOf(1)
79 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
80 expect(files).to.have.lengthOf(3)
81 expect(files[0].resolution.id).to.equal(720)
82 expect(files[1].resolution.id).to.equal(240)
83 expect(files[2].resolution.id).to.equal(0)
88 it('0p transcoded video should not have video', async function () {
90 join(root(), 'test' + servers[ 0 ].internalServerNumber, 'videos', videoUUID + '-0.mp4'),
91 join(root(), 'test' + servers[ 0 ].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')
94 for (const path of paths) {
95 const { audioStream } = await audio.get(path)
96 expect(audioStream[ 'codec_name' ]).to.be.equal('aac')
97 expect(audioStream[ 'bit_rate' ]).to.be.at.most(384 * 8000)
99 const size = await getVideoStreamSize(path)
100 expect(size.height).to.equal(0)
101 expect(size.width).to.equal(0)
105 after(async function () {
106 await cleanupTests(servers)