Transcode audio uploads to lower resolutions
Better consistency
This commit is contained in:
parent
89613cb444
commit
40930fda86
|
@ -382,8 +382,9 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
|
||||||
}
|
}
|
||||||
|
|
||||||
private getUrlWithoutParams () {
|
private getUrlWithoutParams () {
|
||||||
let urlTree = this.router.parseUrl(this.router.url)
|
const urlTree = this.router.parseUrl(this.router.url)
|
||||||
urlTree.queryParams = {}
|
urlTree.queryParams = {}
|
||||||
|
|
||||||
return urlTree.toString()
|
return urlTree.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,8 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio
|
||||||
await mergeAudioVideofile(video, payload.resolution, job)
|
await mergeAudioVideofile(video, payload.resolution, job)
|
||||||
|
|
||||||
await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
|
await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
|
||||||
|
|
||||||
|
await createLowerResolutionsJobs(video, user, payload.resolution, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
|
||||||
|
|
|
@ -43,6 +43,28 @@ import {
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
function updateConfigForTranscoding (server: ServerInfo) {
|
||||||
|
return updateCustomSubConfig(server.url, server.accessToken, {
|
||||||
|
transcoding: {
|
||||||
|
enabled: true,
|
||||||
|
allowAdditionalExtensions: true,
|
||||||
|
allowAudioFiles: true,
|
||||||
|
hls: { enabled: true },
|
||||||
|
webtorrent: { enabled: true },
|
||||||
|
resolutions: {
|
||||||
|
'0p': false,
|
||||||
|
'240p': true,
|
||||||
|
'360p': true,
|
||||||
|
'480p': true,
|
||||||
|
'720p': true,
|
||||||
|
'1080p': true,
|
||||||
|
'1440p': true,
|
||||||
|
'2160p': true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
describe('Test video transcoding', function () {
|
describe('Test video transcoding', function () {
|
||||||
let servers: ServerInfo[] = []
|
let servers: ServerInfo[] = []
|
||||||
let video4k: string
|
let video4k: string
|
||||||
|
@ -56,8 +78,12 @@ describe('Test video transcoding', function () {
|
||||||
await setAccessTokensToServers(servers)
|
await setAccessTokensToServers(servers)
|
||||||
|
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
|
|
||||||
|
await updateConfigForTranscoding(servers[1])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('Basic transcoding (or not)', function () {
|
||||||
|
|
||||||
it('Should not transcode video on server 1', async function () {
|
it('Should not transcode video on server 1', async function () {
|
||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
|
@ -119,6 +145,127 @@ describe('Test video transcoding', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should wait for transcoding before publishing the video', async function () {
|
||||||
|
this.timeout(160_000)
|
||||||
|
|
||||||
|
{
|
||||||
|
// Upload the video, but wait transcoding
|
||||||
|
const videoAttributes = {
|
||||||
|
name: 'waiting video',
|
||||||
|
fixture: 'video_short1.webm',
|
||||||
|
waitTranscoding: true
|
||||||
|
}
|
||||||
|
const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
||||||
|
const videoId = resVideo.body.video.uuid
|
||||||
|
|
||||||
|
// Should be in transcode state
|
||||||
|
const { body } = await getVideo(servers[1].url, videoId)
|
||||||
|
expect(body.name).to.equal('waiting video')
|
||||||
|
expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
|
||||||
|
expect(body.state.label).to.equal('To transcode')
|
||||||
|
expect(body.waitTranscoding).to.be.true
|
||||||
|
|
||||||
|
// Should have my video
|
||||||
|
const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
|
||||||
|
const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
expect(videoToFindInMine).not.to.be.undefined
|
||||||
|
expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
|
||||||
|
expect(videoToFindInMine.state.label).to.equal('To transcode')
|
||||||
|
expect(videoToFindInMine.waitTranscoding).to.be.true
|
||||||
|
|
||||||
|
// Should not list this video
|
||||||
|
const resVideos = await getVideosList(servers[1].url)
|
||||||
|
const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
expect(videoToFindInList).to.be.undefined
|
||||||
|
|
||||||
|
// Server 1 should not have the video yet
|
||||||
|
await getVideo(servers[0].url, videoId, HttpStatusCode.NOT_FOUND_404)
|
||||||
|
}
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideosList(server.url)
|
||||||
|
const videoToFind = res.body.data.find(v => v.name === 'waiting video')
|
||||||
|
expect(videoToFind).not.to.be.undefined
|
||||||
|
|
||||||
|
const res2 = await getVideo(server.url, videoToFind.id)
|
||||||
|
const videoDetails: VideoDetails = res2.body
|
||||||
|
|
||||||
|
expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
|
||||||
|
expect(videoDetails.state.label).to.equal('Published')
|
||||||
|
expect(videoDetails.waitTranscoding).to.be.true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should accept and transcode additional extensions', async function () {
|
||||||
|
this.timeout(300_000)
|
||||||
|
|
||||||
|
let tempFixturePath: string
|
||||||
|
|
||||||
|
{
|
||||||
|
tempFixturePath = await generateHighBitrateVideo()
|
||||||
|
|
||||||
|
const bitrate = await getVideoFileBitrate(tempFixturePath)
|
||||||
|
expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
|
||||||
|
const videoAttributes = {
|
||||||
|
name: fixture,
|
||||||
|
fixture
|
||||||
|
}
|
||||||
|
|
||||||
|
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideosList(server.url)
|
||||||
|
|
||||||
|
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
const res2 = await getVideo(server.url, video.id)
|
||||||
|
const videoDetails = res2.body
|
||||||
|
|
||||||
|
expect(videoDetails.files).to.have.lengthOf(4)
|
||||||
|
|
||||||
|
const magnetUri = videoDetails.files[0].magnetUri
|
||||||
|
expect(magnetUri).to.contain('.mp4')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Should transcode a 4k video', async function () {
|
||||||
|
this.timeout(200_000)
|
||||||
|
|
||||||
|
const videoAttributes = {
|
||||||
|
name: '4k video',
|
||||||
|
fixture: 'video_short_4k.mp4'
|
||||||
|
}
|
||||||
|
|
||||||
|
const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
||||||
|
video4k = resUpload.body.video.uuid
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideo(server.url, video4k)
|
||||||
|
const videoDetails: VideoDetails = res.body
|
||||||
|
|
||||||
|
expect(videoDetails.files).to.have.lengthOf(resolutions.length)
|
||||||
|
|
||||||
|
for (const r of resolutions) {
|
||||||
|
expect(videoDetails.files.find(f => f.resolution.id === r)).to.not.be.undefined
|
||||||
|
expect(videoDetails.streamingPlaylists[0].files.find(f => f.resolution.id === r)).to.not.be.undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Audio transcoding', function () {
|
||||||
|
|
||||||
it('Should transcode high bit rate mp3 to proper bit rate', async function () {
|
it('Should transcode high bit rate mp3 to proper bit rate', async function () {
|
||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
|
@ -210,181 +357,27 @@ describe('Test video transcoding', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should transcode a 60 FPS video', async function () {
|
|
||||||
this.timeout(60_000)
|
|
||||||
|
|
||||||
const videoAttributes = {
|
|
||||||
name: 'my super 30fps name for server 2',
|
|
||||||
description: 'my super 30fps description for server 2',
|
|
||||||
fixture: '60fps_720p_small.mp4'
|
|
||||||
}
|
|
||||||
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
const res = await getVideosList(server.url)
|
|
||||||
|
|
||||||
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
|
||||||
const res2 = await getVideo(server.url, video.id)
|
|
||||||
const videoDetails: VideoDetails = res2.body
|
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(4)
|
|
||||||
expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
|
|
||||||
expect(videoDetails.files[1].fps).to.be.below(31)
|
|
||||||
expect(videoDetails.files[2].fps).to.be.below(31)
|
|
||||||
expect(videoDetails.files[3].fps).to.be.below(31)
|
|
||||||
|
|
||||||
for (const resolution of [ '240', '360', '480' ]) {
|
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
|
||||||
const fps = await getVideoFileFPS(path)
|
|
||||||
|
|
||||||
expect(fps).to.be.below(31)
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
|
|
||||||
const fps = await getVideoFileFPS(path)
|
|
||||||
|
|
||||||
expect(fps).to.be.above(58).and.below(62)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should wait for transcoding before publishing the video', async function () {
|
describe('Audio upload', function () {
|
||||||
this.timeout(160_000)
|
|
||||||
|
|
||||||
{
|
before(async function () {
|
||||||
// Upload the video, but wait transcoding
|
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
|
||||||
const videoAttributes = {
|
transcoding: {
|
||||||
name: 'waiting video',
|
hls: { enabled: true },
|
||||||
fixture: 'video_short1.webm',
|
webtorrent: { enabled: true },
|
||||||
waitTranscoding: true
|
resolutions: {
|
||||||
}
|
'0p': false,
|
||||||
const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
'240p': false,
|
||||||
const videoId = resVideo.body.video.uuid
|
'360p': false,
|
||||||
|
'480p': false,
|
||||||
// Should be in transcode state
|
'720p': false,
|
||||||
const { body } = await getVideo(servers[1].url, videoId)
|
'1080p': false,
|
||||||
expect(body.name).to.equal('waiting video')
|
'1440p': false,
|
||||||
expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
|
'2160p': false
|
||||||
expect(body.state.label).to.equal('To transcode')
|
|
||||||
expect(body.waitTranscoding).to.be.true
|
|
||||||
|
|
||||||
// Should have my video
|
|
||||||
const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
|
|
||||||
const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name)
|
|
||||||
expect(videoToFindInMine).not.to.be.undefined
|
|
||||||
expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
|
|
||||||
expect(videoToFindInMine.state.label).to.equal('To transcode')
|
|
||||||
expect(videoToFindInMine.waitTranscoding).to.be.true
|
|
||||||
|
|
||||||
// Should not list this video
|
|
||||||
const resVideos = await getVideosList(servers[1].url)
|
|
||||||
const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name)
|
|
||||||
expect(videoToFindInList).to.be.undefined
|
|
||||||
|
|
||||||
// Server 1 should not have the video yet
|
|
||||||
await getVideo(servers[0].url, videoId, HttpStatusCode.NOT_FOUND_404)
|
|
||||||
}
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
const res = await getVideosList(server.url)
|
|
||||||
const videoToFind = res.body.data.find(v => v.name === 'waiting video')
|
|
||||||
expect(videoToFind).not.to.be.undefined
|
|
||||||
|
|
||||||
const res2 = await getVideo(server.url, videoToFind.id)
|
|
||||||
const videoDetails: VideoDetails = res2.body
|
|
||||||
|
|
||||||
expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
|
|
||||||
expect(videoDetails.state.label).to.equal('Published')
|
|
||||||
expect(videoDetails.waitTranscoding).to.be.true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Should respect maximum bitrate values', async function () {
|
|
||||||
this.timeout(160_000)
|
|
||||||
|
|
||||||
let tempFixturePath: string
|
|
||||||
|
|
||||||
{
|
|
||||||
tempFixturePath = await generateHighBitrateVideo()
|
|
||||||
|
|
||||||
const bitrate = await getVideoFileBitrate(tempFixturePath)
|
|
||||||
expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
|
|
||||||
}
|
|
||||||
|
|
||||||
const videoAttributes = {
|
|
||||||
name: 'high bitrate video',
|
|
||||||
description: 'high bitrate video',
|
|
||||||
fixture: tempFixturePath
|
|
||||||
}
|
|
||||||
|
|
||||||
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
const res = await getVideosList(server.url)
|
|
||||||
|
|
||||||
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
|
||||||
|
|
||||||
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
|
|
||||||
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
|
||||||
|
|
||||||
const bitrate = await getVideoFileBitrate(path)
|
|
||||||
const fps = await getVideoFileFPS(path)
|
|
||||||
const resolution2 = await getVideoFileResolution(path)
|
|
||||||
|
|
||||||
expect(resolution2.videoFileResolution.toString()).to.equal(resolution)
|
|
||||||
expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should accept and transcode additional extensions', async function () {
|
|
||||||
this.timeout(300_000)
|
|
||||||
|
|
||||||
let tempFixturePath: string
|
|
||||||
|
|
||||||
{
|
|
||||||
tempFixturePath = await generateHighBitrateVideo()
|
|
||||||
|
|
||||||
const bitrate = await getVideoFileBitrate(tempFixturePath)
|
|
||||||
expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
|
|
||||||
const videoAttributes = {
|
|
||||||
name: fixture,
|
|
||||||
fixture
|
|
||||||
}
|
|
||||||
|
|
||||||
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
const res = await getVideosList(server.url)
|
|
||||||
|
|
||||||
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
|
||||||
const res2 = await getVideo(server.url, video.id)
|
|
||||||
const videoDetails = res2.body
|
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(4)
|
|
||||||
|
|
||||||
const magnetUri = videoDetails.files[0].magnetUri
|
|
||||||
expect(magnetUri).to.contain('.mp4')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Should correctly detect if quick transcode is possible', async function () {
|
|
||||||
this.timeout(10_000)
|
|
||||||
|
|
||||||
expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true
|
|
||||||
expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should merge an audio file with the preview file', async function () {
|
it('Should merge an audio file with the preview file', async function () {
|
||||||
|
@ -437,6 +430,81 @@ describe('Test video transcoding', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should upload an audio file and create an audio version only', async function () {
|
||||||
|
this.timeout(60_000)
|
||||||
|
|
||||||
|
await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
|
||||||
|
transcoding: {
|
||||||
|
hls: { enabled: true },
|
||||||
|
webtorrent: { enabled: true },
|
||||||
|
resolutions: {
|
||||||
|
'0p': true,
|
||||||
|
'240p': false,
|
||||||
|
'360p': false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
|
||||||
|
const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg)
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res2 = await getVideo(server.url, resVideo.body.video.id)
|
||||||
|
const videoDetails: VideoDetails = res2.body
|
||||||
|
|
||||||
|
for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
|
||||||
|
expect(files).to.have.lengthOf(2)
|
||||||
|
expect(files.find(f => f.resolution.id === 0)).to.not.be.undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await updateConfigForTranscoding(servers[1])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Framerate', function () {
|
||||||
|
|
||||||
|
it('Should transcode a 60 FPS video', async function () {
|
||||||
|
this.timeout(60_000)
|
||||||
|
|
||||||
|
const videoAttributes = {
|
||||||
|
name: 'my super 30fps name for server 2',
|
||||||
|
description: 'my super 30fps description for server 2',
|
||||||
|
fixture: '60fps_720p_small.mp4'
|
||||||
|
}
|
||||||
|
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideosList(server.url)
|
||||||
|
|
||||||
|
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
const res2 = await getVideo(server.url, video.id)
|
||||||
|
const videoDetails: VideoDetails = res2.body
|
||||||
|
|
||||||
|
expect(videoDetails.files).to.have.lengthOf(4)
|
||||||
|
expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
|
||||||
|
expect(videoDetails.files[1].fps).to.be.below(31)
|
||||||
|
expect(videoDetails.files[2].fps).to.be.below(31)
|
||||||
|
expect(videoDetails.files[3].fps).to.be.below(31)
|
||||||
|
|
||||||
|
for (const resolution of [ '240', '360', '480' ]) {
|
||||||
|
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
||||||
|
const fps = await getVideoFileFPS(path)
|
||||||
|
|
||||||
|
expect(fps).to.be.below(31)
|
||||||
|
}
|
||||||
|
|
||||||
|
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
|
||||||
|
const fps = await getVideoFileFPS(path)
|
||||||
|
|
||||||
|
expect(fps).to.be.above(58).and.below(62)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('Should downscale to the closest divisor standard framerate', async function () {
|
it('Should downscale to the closest divisor standard framerate', async function () {
|
||||||
this.timeout(200_000)
|
this.timeout(200_000)
|
||||||
|
|
||||||
|
@ -477,6 +545,48 @@ describe('Test video transcoding', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Bitrate control', function () {
|
||||||
|
it('Should respect maximum bitrate values', async function () {
|
||||||
|
this.timeout(160_000)
|
||||||
|
|
||||||
|
let tempFixturePath: string
|
||||||
|
|
||||||
|
{
|
||||||
|
tempFixturePath = await generateHighBitrateVideo()
|
||||||
|
|
||||||
|
const bitrate = await getVideoFileBitrate(tempFixturePath)
|
||||||
|
expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
|
||||||
|
}
|
||||||
|
|
||||||
|
const videoAttributes = {
|
||||||
|
name: 'high bitrate video',
|
||||||
|
description: 'high bitrate video',
|
||||||
|
fixture: tempFixturePath
|
||||||
|
}
|
||||||
|
|
||||||
|
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideosList(server.url)
|
||||||
|
|
||||||
|
const video = res.body.data.find(v => v.name === videoAttributes.name)
|
||||||
|
|
||||||
|
for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
|
||||||
|
const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
|
||||||
|
|
||||||
|
const bitrate = await getVideoFileBitrate(path)
|
||||||
|
const fps = await getVideoFileFPS(path)
|
||||||
|
const resolution2 = await getVideoFileResolution(path)
|
||||||
|
|
||||||
|
expect(resolution2.videoFileResolution.toString()).to.equal(resolution)
|
||||||
|
expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('Should not transcode to an higher bitrate than the original file', async function () {
|
it('Should not transcode to an higher bitrate than the original file', async function () {
|
||||||
this.timeout(160_000)
|
this.timeout(160_000)
|
||||||
|
@ -516,6 +626,9 @@ describe('Test video transcoding', function () {
|
||||||
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
|
expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('FFprobe', function () {
|
||||||
|
|
||||||
it('Should provide valid ffprobe data', async function () {
|
it('Should provide valid ffprobe data', async function () {
|
||||||
this.timeout(160_000)
|
this.timeout(160_000)
|
||||||
|
@ -574,33 +687,15 @@ describe('Test video transcoding', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should transcode a 4k video', async function () {
|
it('Should correctly detect if quick transcode is possible', async function () {
|
||||||
this.timeout(200_000)
|
this.timeout(10_000)
|
||||||
|
|
||||||
const videoAttributes = {
|
expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true
|
||||||
name: '4k video',
|
expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false
|
||||||
fixture: 'video_short_4k.mp4'
|
|
||||||
}
|
|
||||||
|
|
||||||
const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
|
|
||||||
video4k = resUpload.body.video.uuid
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
const res = await getVideo(server.url, video4k)
|
|
||||||
const videoDetails: VideoDetails = res.body
|
|
||||||
|
|
||||||
expect(videoDetails.files).to.have.lengthOf(resolutions.length)
|
|
||||||
|
|
||||||
for (const r of resolutions) {
|
|
||||||
expect(videoDetails.files.find(f => f.resolution.id === r)).to.not.be.undefined
|
|
||||||
expect(videoDetails.streamingPlaylists[0].files.find(f => f.resolution.id === r)).to.not.be.undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Transcoding job queue', function () {
|
||||||
|
|
||||||
it('Should have the appropriate priorities for transcoding jobs', async function () {
|
it('Should have the appropriate priorities for transcoding jobs', async function () {
|
||||||
const res = await getJobsListPaginationAndSort({
|
const res = await getJobsListPaginationAndSort({
|
||||||
|
@ -636,6 +731,7 @@ describe('Test video transcoding', function () {
|
||||||
expect(j.priority).to.be.lessThan(150)
|
expect(j.priority).to.be.lessThan(150)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
await cleanupTests(servers)
|
await cleanupTests(servers)
|
||||||
|
|
Loading…
Reference in New Issue