1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Fix audio issues with live replay

This commit is contained in:
Chocobozzz 2020-12-04 15:10:13 +01:00
parent 49bcdb0d66
commit 3851e732c4
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 49 additions and 68 deletions

View file

@ -1,4 +1,4 @@
import { copyFile, ensureDir, move, remove, stat, writeFile } from 'fs-extra'
import { copyFile, ensureDir, move, remove, stat } from 'fs-extra'
import { basename, extname as extnameUtil, join } from 'path'
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
import { MStreamingPlaylistFilesVideo, MVideoFile, MVideoWithAllFiles, MVideoWithFile } from '@server/types/models'
@ -166,41 +166,17 @@ async function mergeAudioVideofile (video: MVideoWithAllFiles, resolution: Video
// Concat TS segments from a live video to a fragmented mp4 HLS playlist
async function generateHlsPlaylistFromTS (options: {
video: MVideoWithFile
replayDirectory: string
segmentFiles: string[]
concatenatedTsFilePath: string
resolution: VideoResolution
isPortraitMode: boolean
}) {
const concatFilePath = join(options.replayDirectory, 'concat.txt')
function cleaner () {
remove(concatFilePath)
.catch(err => logger.error('Cannot remove concat file in %s.', options.replayDirectory, { err }))
}
// First concat the ts files to a mp4 file
const content = options.segmentFiles.map(f => 'file ' + f)
.join('\n')
await writeFile(concatFilePath, content + '\n')
try {
const outputPath = await generateHlsPlaylistCommon({
video: options.video,
resolution: options.resolution,
isPortraitMode: options.isPortraitMode,
inputPath: concatFilePath,
type: 'hls-from-ts' as 'hls-from-ts'
})
cleaner()
return outputPath
} catch (err) {
cleaner()
throw err
}
return generateHlsPlaylistCommon({
video: options.video,
resolution: options.resolution,
isPortraitMode: options.isPortraitMode,
inputPath: options.concatenatedTsFilePath,
type: 'hls-from-ts' as 'hls-from-ts'
})
}
// Generate an HLS playlist from an input file, and update the master playlist