mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Create and inject caption playlist in HLS master
This commit is contained in:
parent
a7be820abc
commit
6e44e7e29a
49 changed files with 1368 additions and 401 deletions
|
@ -4,8 +4,8 @@ import { Transform } from 'stream'
|
|||
import { MVideoCaption } from '@server/types/models/index.js'
|
||||
import { pipelinePromise } from './core-utils.js'
|
||||
|
||||
async function moveAndProcessCaptionFile (physicalFile: { filename?: string, path: string }, videoCaption: MVideoCaption) {
|
||||
const destination = videoCaption.getFSPath()
|
||||
export async function moveAndProcessCaptionFile (physicalFile: { filename?: string, path: string }, videoCaption: MVideoCaption) {
|
||||
const destination = videoCaption.getFSFilePath()
|
||||
|
||||
// Convert this srt file to vtt
|
||||
if (physicalFile.path.endsWith('.srt')) {
|
||||
|
@ -22,20 +22,14 @@ async function moveAndProcessCaptionFile (physicalFile: { filename?: string, pat
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
moveAndProcessCaptionFile
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function convertSrtToVtt (source: string, destination: string) {
|
||||
const fixVTT = new Transform({
|
||||
transform: (chunk, _encoding, cb) => {
|
||||
let block: string = chunk.toString()
|
||||
|
||||
block = block.replace(/(\d\d:\d\d:\d\d)(\s)/g, '$1.000$2')
|
||||
.replace(/(\d\d:\d\d:\d\d),(\d)(\s)/g, '$1.00$2$3')
|
||||
.replace(/(\d\d:\d\d:\d\d),(\d\d)(\s)/g, '$1.0$2$3')
|
||||
.replace(/(\d\d:\d\d:\d\d),(\d)(\s)/g, '$1.00$2$3')
|
||||
.replace(/(\d\d:\d\d:\d\d),(\d\d)(\s)/g, '$1.0$2$3')
|
||||
|
||||
return cb(undefined, block)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue