aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-transcoding.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r--server/lib/video-transcoding.ts42
1 files changed, 9 insertions, 33 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index 890b23a44..44ecf4cc9 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,4 +1,4 @@
1import { copyFile, ensureDir, move, remove, stat, writeFile } from 'fs-extra' 1import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
2import { basename, extname as extnameUtil, join } from 'path' 2import { basename, extname as extnameUtil, join } from 'path'
3import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 3import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
4import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models' 4import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
@@ -166,41 +166,17 @@ async function mergeAudioVideofile (video: MVideoWithAllFiles, resolution: Video
166// Concat TS segments from a live video to a fragmented mp4 HLS playlist 166// Concat TS segments from a live video to a fragmented mp4 HLS playlist
167async function generateHlsPlaylistFromTS (options: { 167async function generateHlsPlaylistFromTS (options: {
168 video: MVideoWithFile 168 video: MVideoWithFile
169 replayDirectory: string 169 concatenatedTsFilePath: string
170 segmentFiles: string[]
171 resolution: VideoResolution 170 resolution: VideoResolution
172 isPortraitMode: boolean 171 isPortraitMode: boolean
173}) { 172}) {
174 const concatFilePath = join(options.replayDirectory, 'concat.txt') 173 return generateHlsPlaylistCommon({
175 174 video: options.video,
176 function cleaner () { 175 resolution: options.resolution,
177 remove(concatFilePath) 176 isPortraitMode: options.isPortraitMode,
178 .catch(err => logger.error('Cannot remove concat file in %s.', options.replayDirectory, { err })) 177 inputPath: options.concatenatedTsFilePath,
179 } 178 type: 'hls-from-ts' as 'hls-from-ts'
180 179 })
181 // First concat the ts files to a mp4 file
182 const content = options.segmentFiles.map(f => 'file ' + f)
183 .join('\n')
184
185 await writeFile(concatFilePath, content + '\n')
186
187 try {
188 const outputPath = await generateHlsPlaylistCommon({
189 video: options.video,
190 resolution: options.resolution,
191 isPortraitMode: options.isPortraitMode,
192 inputPath: concatFilePath,
193 type: 'hls-from-ts' as 'hls-from-ts'
194 })
195
196 cleaner()
197
198 return outputPath
199 } catch (err) {
200 cleaner()
201
202 throw err
203 }
204} 180}
205 181
206// Generate an HLS playlist from an input file, and update the master playlist 182// Generate an HLS playlist from an input file, and update the master playlist