+ const video = data.find(v => v.name === attributes.name)
+ const videoDetails = await server.videos.get({ id: video.id })
+
+ expect(videoDetails.files).to.have.lengthOf(5)
+
+ const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
+ const fixtureVideoProbe = await getAudioStream(fixturePath)
+
+ const file = videoDetails.files.find(f => f.resolution.id === 240)
+ const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
+
+ const videoProbe = await getAudioStream(path)
+
+ if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
+ const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
+ expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
+ } else {
+ this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath)
+ }
+ }
+ })
+ })
+
+ describe('Audio upload', function () {
+
+ function runSuite (mode: 'legacy' | 'resumable') {
+
+ before(async function () {
+ await servers[1].config.updateCustomSubConfig({
+ newConfig: {
+ transcoding: {
+ hls: { enabled: true },
+ webtorrent: { enabled: true },
+ resolutions: {
+ '0p': false,
+ '144p': false,
+ '240p': false,
+ '360p': false,
+ '480p': false,
+ '720p': false,
+ '1080p': false,
+ '1440p': false,
+ '2160p': false
+ }
+ }
+ }
+ })
+ })
+
+ it('Should merge an audio file with the preview file', async function () {
+ this.timeout(60_000)
+
+ const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
+ await servers[1].videos.upload({ attributes, mode })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const { data } = await server.videos.list()
+
+ const video = data.find(v => v.name === 'audio_with_preview')
+ const videoDetails = await server.videos.get({ id: video.id })
+
+ expect(videoDetails.files).to.have.lengthOf(1)
+
+ await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
+
+ const magnetUri = videoDetails.files[0].magnetUri
+ expect(magnetUri).to.contain('.mp4')
+ }
+ })
+
+ it('Should upload an audio file and choose a default background image', async function () {
+ this.timeout(60_000)
+
+ const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }
+ await servers[1].videos.upload({ attributes, mode })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const { data } = await server.videos.list()
+
+ const video = data.find(v => v.name === 'audio_without_preview')
+ const videoDetails = await server.videos.get({ id: video.id })
+
+ expect(videoDetails.files).to.have.lengthOf(1)
+
+ await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
+
+ const magnetUri = videoDetails.files[0].magnetUri
+ expect(magnetUri).to.contain('.mp4')
+ }
+ })
+
+ it('Should upload an audio file and create an audio version only', async function () {
+ this.timeout(60_000)
+
+ await servers[1].config.updateCustomSubConfig({
+ newConfig: {
+ transcoding: {
+ hls: { enabled: true },
+ webtorrent: { enabled: true },
+ resolutions: {
+ '0p': true,
+ '144p': false,
+ '240p': false,
+ '360p': false
+ }
+ }
+ }
+ })
+
+ const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
+ const { id } = await servers[1].videos.upload({ attributes, mode })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const videoDetails = await server.videos.get({ id })
+
+ 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])
+ })