diff options
Diffstat (limited to 'server/tests/api/videos/video-hls.ts')
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 504c50dee..eacd9ab79 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -21,12 +21,11 @@ import { | |||
21 | import { VideoDetails } from '../../../../shared/models/videos' | 21 | import { VideoDetails } from '../../../../shared/models/videos' |
22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' | 22 | import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' |
23 | import { join } from 'path' | 23 | import { join } from 'path' |
24 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | ||
24 | 25 | ||
25 | const expect = chai.expect | 26 | const expect = chai.expect |
26 | 27 | ||
27 | async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | 28 | async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, resolutions = [ 240, 360, 480, 720 ]) { |
28 | const resolutions = [ 240, 360, 480, 720 ] | ||
29 | |||
30 | for (const server of servers) { | 29 | for (const server of servers) { |
31 | const res = await getVideo(server.url, videoUUID) | 30 | const res = await getVideo(server.url, videoUUID) |
32 | const videoDetails: VideoDetails = res.body | 31 | const videoDetails: VideoDetails = res.body |
@@ -41,9 +40,8 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
41 | 40 | ||
42 | const masterPlaylist = res2.text | 41 | const masterPlaylist = res2.text |
43 | 42 | ||
44 | expect(masterPlaylist).to.contain('#EXT-X-STREAM-INF:BANDWIDTH=55472,RESOLUTION=640x360,FRAME-RATE=25') | ||
45 | |||
46 | for (const resolution of resolutions) { | 43 | for (const resolution of resolutions) { |
44 | expect(masterPlaylist).to.match(new RegExp('#EXT-X-STREAM-INF:BANDWIDTH=\\d+,RESOLUTION=\\d+x' + resolution + ',FRAME-RATE=\\d+')) | ||
47 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) | 45 | expect(masterPlaylist).to.contain(`${resolution}.m3u8`) |
48 | } | 46 | } |
49 | } | 47 | } |
@@ -70,11 +68,21 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
70 | describe('Test HLS videos', function () { | 68 | describe('Test HLS videos', function () { |
71 | let servers: ServerInfo[] = [] | 69 | let servers: ServerInfo[] = [] |
72 | let videoUUID = '' | 70 | let videoUUID = '' |
71 | let videoAudioUUID = '' | ||
73 | 72 | ||
74 | before(async function () { | 73 | before(async function () { |
75 | this.timeout(120000) | 74 | this.timeout(120000) |
76 | 75 | ||
77 | servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: true, hls: { enabled: true } } }) | 76 | const configOverride = { |
77 | transcoding: { | ||
78 | enabled: true, | ||
79 | allow_audio_files: true, | ||
80 | hls: { | ||
81 | enabled: true | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | servers = await flushAndRunMultipleServers(2, configOverride) | ||
78 | 86 | ||
79 | // Get the access tokens | 87 | // Get the access tokens |
80 | await setAccessTokensToServers(servers) | 88 | await setAccessTokensToServers(servers) |
@@ -86,16 +94,25 @@ describe('Test HLS videos', function () { | |||
86 | it('Should upload a video and transcode it to HLS', async function () { | 94 | it('Should upload a video and transcode it to HLS', async function () { |
87 | this.timeout(120000) | 95 | this.timeout(120000) |
88 | 96 | ||
89 | { | 97 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) |
90 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) | 98 | videoUUID = res.body.video.uuid |
91 | videoUUID = res.body.video.uuid | ||
92 | } | ||
93 | 99 | ||
94 | await waitJobs(servers) | 100 | await waitJobs(servers) |
95 | 101 | ||
96 | await checkHlsPlaylist(servers, videoUUID) | 102 | await checkHlsPlaylist(servers, videoUUID) |
97 | }) | 103 | }) |
98 | 104 | ||
105 | it('Should upload an audio file and transcode it to HLS', async function () { | ||
106 | this.timeout(120000) | ||
107 | |||
108 | const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) | ||
109 | videoAudioUUID = res.body.video.uuid | ||
110 | |||
111 | await waitJobs(servers) | ||
112 | |||
113 | await checkHlsPlaylist(servers, videoAudioUUID, [ DEFAULT_AUDIO_RESOLUTION ]) | ||
114 | }) | ||
115 | |||
99 | it('Should update the video', async function () { | 116 | it('Should update the video', async function () { |
100 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) | 117 | await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) |
101 | 118 | ||
@@ -104,13 +121,15 @@ describe('Test HLS videos', function () { | |||
104 | await checkHlsPlaylist(servers, videoUUID) | 121 | await checkHlsPlaylist(servers, videoUUID) |
105 | }) | 122 | }) |
106 | 123 | ||
107 | it('Should delete the video', async function () { | 124 | it('Should delete videos', async function () { |
108 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) | 125 | await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) |
126 | await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) | ||
109 | 127 | ||
110 | await waitJobs(servers) | 128 | await waitJobs(servers) |
111 | 129 | ||
112 | for (const server of servers) { | 130 | for (const server of servers) { |
113 | await getVideo(server.url, videoUUID, 404) | 131 | await getVideo(server.url, videoUUID, 404) |
132 | await getVideo(server.url, videoAudioUUID, 404) | ||
114 | } | 133 | } |
115 | }) | 134 | }) |
116 | 135 | ||