diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 94 | ||||
-rw-r--r-- | server/tests/fixtures/video_short_mp3_256k.mp4 | bin | 0 -> 194985 bytes | |||
-rw-r--r-- | server/tests/fixtures/video_short_no_audio.mp4 | bin | 0 -> 34259 bytes | |||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 2 |
4 files changed, 91 insertions, 5 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 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { omit } from 'lodash' | ||
6 | import * as ffmpeg from 'fluent-ffmpeg' | ||
5 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' | 7 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' |
6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' | 8 | import { getVideoFileFPS, audio } from '../../../helpers/ffmpeg-utils' |
7 | import { | 9 | import { |
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 |
diff --git a/server/tests/fixtures/video_short_mp3_256k.mp4 b/server/tests/fixtures/video_short_mp3_256k.mp4 new file mode 100644 index 000000000..4c1c7b45e --- /dev/null +++ b/server/tests/fixtures/video_short_mp3_256k.mp4 | |||
Binary files differ | |||
diff --git a/server/tests/fixtures/video_short_no_audio.mp4 b/server/tests/fixtures/video_short_no_audio.mp4 new file mode 100644 index 000000000..329d20fba --- /dev/null +++ b/server/tests/fixtures/video_short_no_audio.mp4 | |||
Binary files differ | |||
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index a9d449c58..b280cccda 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -523,7 +523,7 @@ async function completeVideoCheck ( | |||
523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | 523 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) |
524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 524 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
525 | expect(file.size, | 525 | expect(file.size, |
526 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval.') | 526 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') |
527 | .to.be.above(minSize).and.below(maxSize) | 527 | .to.be.above(minSize).and.below(maxSize) |
528 | 528 | ||
529 | { | 529 | { |