diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-04 15:10:13 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-04 15:10:13 +0100 |
commit | 3851e732c4b1da0bc0c40a46ed5a89d93cdc5389 (patch) | |
tree | 67ccc78a4f695fe9eb682b8056368ca9de6b1306 /server/lib/video-transcoding.ts | |
parent | 49bcdb0d6699f19d359f40e974cdffd93a4b34c7 (diff) | |
download | PeerTube-3851e732c4b1da0bc0c40a46ed5a89d93cdc5389.tar.gz PeerTube-3851e732c4b1da0bc0c40a46ed5a89d93cdc5389.tar.zst PeerTube-3851e732c4b1da0bc0c40a46ed5a89d93cdc5389.zip |
Fix audio issues with live replay
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r-- | server/lib/video-transcoding.ts | 42 |
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 @@ | |||
1 | import { copyFile, ensureDir, move, remove, stat, writeFile } from 'fs-extra' | 1 | import { copyFile, ensureDir, move, remove, stat } from 'fs-extra' |
2 | import { basename, extname as extnameUtil, join } from 'path' | 2 | import { basename, extname as extnameUtil, join } from 'path' |
3 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 3 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
4 | import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models' | 4 | import { 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 |
167 | async function generateHlsPlaylistFromTS (options: { | 167 | async 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 |