+ const magnetUri = videoDetails.files[0].magnetUri
+ expect(magnetUri).to.match(/\.mp4/)
+
+ const torrent = await webtorrentAdd(magnetUri, true)
+ expect(torrent.files).to.be.an('array')
+ expect(torrent.files.length).to.equal(1)
+ expect(torrent.files[0].path).match(/\.mp4$/)
+ }
+ })
+
+ it('Should wait for transcoding before publishing the video', async function () {
+ this.timeout(160_000)
+
+ {
+ // Upload the video, but wait transcoding
+ const attributes = {
+ name: 'waiting video',
+ fixture: 'video_short1.webm',
+ waitTranscoding: true
+ }
+ const { uuid } = await servers[1].videos.upload({ attributes })
+ const videoId = uuid
+
+ // Should be in transcode state
+ const body = await servers[1].videos.get({ id: 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 { data } = await servers[1].videos.listMyVideos()
+ const videoToFindInMine = data.find(v => v.name === attributes.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 { data } = await servers[1].videos.list()
+ const videoToFindInList = data.find(v => v.name === attributes.name)
+ expect(videoToFindInList).to.be.undefined
+ }
+
+ // Server 1 should not have the video yet
+ await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ }
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const { data } = await server.videos.list()
+ const videoToFind = data.find(v => v.name === 'waiting video')
+ expect(videoToFind).not.to.be.undefined
+
+ const videoDetails = await server.videos.get({ id: videoToFind.id })
+
+ 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 attributes = {
+ name: fixture,
+ fixture
+ }
+
+ await servers[1].videos.upload({ attributes })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const { data } = await server.videos.list()
+
+ const video = data.find(v => v.name === attributes.name)
+ const videoDetails = await server.videos.get({ id: video.id })
+ 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 attributes = {
+ name: '4k video',
+ fixture: 'video_short_4k.mp4'
+ }
+
+ const { uuid } = await servers[1].videos.upload({ attributes })
+ video4k = uuid
+
+ await waitJobs(servers)
+
+ const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
+
+ for (const server of servers) {
+ const videoDetails = await server.videos.get({ id: video4k })
+ 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
+ }
+ }
+ })