2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2019-11-22 04:43:17 -06:00
|
|
|
|
|
|
|
import 'mocha'
|
2020-11-20 10:16:55 -06:00
|
|
|
import * as chai from 'chai'
|
|
|
|
import { join } from 'path'
|
|
|
|
import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
|
2019-11-22 04:43:17 -06:00
|
|
|
import {
|
|
|
|
cleanupTests,
|
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
2020-01-31 09:56:52 -06:00
|
|
|
getVideo,
|
2019-11-22 04:43:17 -06:00
|
|
|
ServerInfo,
|
2020-01-31 09:56:52 -06:00
|
|
|
setAccessTokensToServers,
|
2019-11-22 04:43:17 -06:00
|
|
|
uploadVideo,
|
2020-01-31 09:56:52 -06:00
|
|
|
waitJobs
|
2019-11-22 04:43:17 -06:00
|
|
|
} from '../../../../shared/extra-utils'
|
|
|
|
import { VideoDetails } from '../../../../shared/models/videos'
|
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test audio only video transcoding', function () {
|
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
let videoUUID: string
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
|
|
|
const configOverride = {
|
|
|
|
transcoding: {
|
|
|
|
enabled: true,
|
|
|
|
resolutions: {
|
|
|
|
'0p': true,
|
|
|
|
'240p': true,
|
|
|
|
'360p': false,
|
|
|
|
'480p': false,
|
|
|
|
'720p': false,
|
|
|
|
'1080p': false,
|
2020-12-24 11:02:04 -06:00
|
|
|
'1440p': false,
|
2019-11-22 04:43:17 -06:00
|
|
|
'2160p': false
|
|
|
|
},
|
|
|
|
hls: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
webtorrent: {
|
|
|
|
enabled: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
servers = await flushAndRunMultipleServers(2, configOverride)
|
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
// Server 1 and server 2 follow each other
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should upload a video and transcode it', async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
2019-11-25 09:53:44 -06:00
|
|
|
const resUpload = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'audio only' })
|
2019-11-22 04:43:17 -06:00
|
|
|
videoUUID = resUpload.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
for (const server of servers) {
|
|
|
|
const res = await getVideo(server.url, videoUUID)
|
|
|
|
const video: VideoDetails = res.body
|
|
|
|
|
|
|
|
expect(video.streamingPlaylists).to.have.lengthOf(1)
|
|
|
|
|
|
|
|
for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
|
|
|
|
expect(files).to.have.lengthOf(3)
|
|
|
|
expect(files[0].resolution.id).to.equal(720)
|
|
|
|
expect(files[1].resolution.id).to.equal(240)
|
|
|
|
expect(files[2].resolution.id).to.equal(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('0p transcoded video should not have video', async function () {
|
|
|
|
const paths = [
|
2021-07-13 02:43:59 -05:00
|
|
|
servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')),
|
|
|
|
servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
|
2019-11-22 04:43:17 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
for (const path of paths) {
|
2020-11-20 10:16:55 -06:00
|
|
|
const { audioStream } = await getAudioStream(path)
|
2020-01-31 09:56:52 -06:00
|
|
|
expect(audioStream['codec_name']).to.be.equal('aac')
|
|
|
|
expect(audioStream['bit_rate']).to.be.at.most(384 * 8000)
|
2019-11-22 04:43:17 -06:00
|
|
|
|
2019-11-26 09:25:36 -06:00
|
|
|
const size = await getVideoStreamSize(path)
|
2019-11-22 04:43:17 -06:00
|
|
|
expect(size.height).to.equal(0)
|
|
|
|
expect(size.width).to.equal(0)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
|
|
|
await cleanupTests(servers)
|
|
|
|
})
|
|
|
|
})
|