aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts94
1 files changed, 90 insertions, 4 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index fe750253e..4a39ee3e3 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -2,9 +2,12 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { omit } from 'lodash'
6import * as ffmpeg from 'fluent-ffmpeg'
5import { VideoDetails, VideoState } from '../../../../shared/models/videos' 7import { VideoDetails, VideoState } from '../../../../shared/models/videos'
6import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' 8import { getVideoFileFPS, audio } from '../../../helpers/ffmpeg-utils'
7import { 9import {
10 buildAbsoluteFixturePath,
8 doubleFollow, 11 doubleFollow,
9 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
10 getMyVideos, 13 getMyVideos,
@@ -91,6 +94,89 @@ describe('Test video transcoding', function () {
91 expect(torrent.files[0].path).match(/\.mp4$/) 94 expect(torrent.files[0].path).match(/\.mp4$/)
92 }) 95 })
93 96
97 it('Should transcode high bit rate mp3 to proper bit rate', async function () {
98 this.timeout(60000)
99
100 const videoAttributes = {
101 name: 'mp3_256k',
102 fixture: 'video_short_mp3_256k.mp4'
103 }
104 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
105
106 await waitJobs(servers)
107
108 const res = await getVideosList(servers[1].url)
109
110 const video = res.body.data.find(v => v.name === videoAttributes.name)
111 const res2 = await getVideo(servers[1].url, video.id)
112 const videoDetails: VideoDetails = res2.body
113
114 expect(videoDetails.files).to.have.lengthOf(4)
115
116 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
117 const probe = await audio.get(ffmpeg, path)
118
119 if (probe.audioStream) {
120 expect(probe.audioStream['codec_name']).to.be.equal('aac')
121 expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000)
122 } else {
123 this.fail('Could not retrieve the audio stream on ' + probe.absolutePath)
124 }
125 })
126
127 it('Should transcode video with no audio and have no audio itself', async function () {
128 this.timeout(60000)
129
130 const videoAttributes = {
131 name: 'no_audio',
132 fixture: 'video_short_no_audio.mp4'
133 }
134 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
135
136 await waitJobs(servers)
137
138 const res = await getVideosList(servers[1].url)
139
140 const video = res.body.data.find(v => v.name === videoAttributes.name)
141 const res2 = await getVideo(servers[1].url, video.id)
142 const videoDetails: VideoDetails = res2.body
143
144 expect(videoDetails.files).to.have.lengthOf(4)
145 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
146 const probe = await audio.get(ffmpeg, path)
147 expect(probe).to.not.have.property('audioStream')
148 })
149
150 it('Should leave the audio untouched, but properly transcode the video', async function () {
151 this.timeout(60000)
152
153 const videoAttributes = {
154 name: 'untouched_audio',
155 fixture: 'video_short.mp4'
156 }
157 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
158
159 await waitJobs(servers)
160
161 const res = await getVideosList(servers[1].url)
162
163 const video = res.body.data.find(v => v.name === videoAttributes.name)
164 const res2 = await getVideo(servers[1].url, video.id)
165 const videoDetails: VideoDetails = res2.body
166
167 expect(videoDetails.files).to.have.lengthOf(4)
168 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
169 const fixtureVideoProbe = await audio.get(ffmpeg, fixturePath)
170 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4')
171 const videoProbe = await audio.get(ffmpeg, path)
172 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
173 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
174 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
175 } else {
176 this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath)
177 }
178 })
179
94 it('Should transcode a 60 FPS video', async function () { 180 it('Should transcode a 60 FPS video', async function () {
95 this.timeout(60000) 181 this.timeout(60000)
96 182
@@ -105,7 +191,7 @@ describe('Test video transcoding', function () {
105 191
106 const res = await getVideosList(servers[1].url) 192 const res = await getVideosList(servers[1].url)
107 193
108 const video = res.body.data[0] 194 const video = res.body.data.find(v => v.name === videoAttributes.name)
109 const res2 = await getVideo(servers[1].url, video.id) 195 const res2 = await getVideo(servers[1].url, video.id)
110 const videoDetails: VideoDetails = res2.body 196 const videoDetails: VideoDetails = res2.body
111 197
@@ -154,7 +240,7 @@ describe('Test video transcoding', function () {
154 240
155 // Should have my video 241 // Should have my video
156 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) 242 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
157 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video') 243 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name)
158 expect(videoToFindInMine).not.to.be.undefined 244 expect(videoToFindInMine).not.to.be.undefined
159 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) 245 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
160 expect(videoToFindInMine.state.label).to.equal('To transcode') 246 expect(videoToFindInMine.state.label).to.equal('To transcode')
@@ -162,7 +248,7 @@ describe('Test video transcoding', function () {
162 248
163 // Should not list this video 249 // Should not list this video
164 const resVideos = await getVideosList(servers[1].url) 250 const resVideos = await getVideosList(servers[1].url)
165 const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video') 251 const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name)
166 expect(videoToFindInList).to.be.undefined 252 expect(videoToFindInList).to.be.undefined
167 253
168 // Server 1 should not have the video yet 254 // Server 1 should not have the video yet