mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +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,15 +4,16 @@ import { sequelizeTypescript } from '@server/initializers/database.js'
|
|||
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos/federate.js'
|
||||
import { VideoPathManager } from '@server/lib/video-path-manager.js'
|
||||
import { VideoCaptionModel } from '@server/models/video/video-caption.js'
|
||||
import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js'
|
||||
import { VideoModel } from '@server/models/video/video.js'
|
||||
import { MVideoCaption } from '@server/types/models/index.js'
|
||||
import { MStreamingPlaylistVideoUUID, MVideoCaption } from '@server/types/models/index.js'
|
||||
|
||||
export async function moveCaptionToStorageJob (options: {
|
||||
jobId: string
|
||||
captionId: number
|
||||
loggerTags: (number | string)[]
|
||||
|
||||
moveCaptionFiles: (captions: MVideoCaption[]) => Promise<void>
|
||||
moveCaptionFiles: (captions: MVideoCaption[], hls: MStreamingPlaylistVideoUUID) => Promise<void>
|
||||
}) {
|
||||
const {
|
||||
jobId,
|
||||
|
@ -32,8 +33,10 @@ export async function moveCaptionToStorageJob (options: {
|
|||
|
||||
const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(caption.Video.uuid)
|
||||
|
||||
const hls = await VideoStreamingPlaylistModel.loadHLSByVideoWithVideo(caption.videoId)
|
||||
|
||||
try {
|
||||
await moveCaptionFiles([ caption ])
|
||||
await moveCaptionFiles([ caption ], hls)
|
||||
|
||||
await retryTransactionWrapper(() => {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { VideoCaptionModel } from '@server/models/video/video-caption.js'
|
|||
import { VideoJobInfoModel } from '@server/models/video/video-job-info.js'
|
||||
import { VideoSourceModel } from '@server/models/video/video-source.js'
|
||||
import { VideoModel } from '@server/models/video/video.js'
|
||||
import { MVideoCaption, MVideoWithAllFiles } from '@server/types/models/index.js'
|
||||
import { MStreamingPlaylistVideoUUID, MVideoCaption, MVideoWithAllFiles } from '@server/types/models/index.js'
|
||||
import { MVideoSource } from '@server/types/models/video/video-source.js'
|
||||
|
||||
export async function moveVideoToStorageJob (options: {
|
||||
|
@ -15,7 +15,7 @@ export async function moveVideoToStorageJob (options: {
|
|||
moveWebVideoFiles: (video: MVideoWithAllFiles) => Promise<void>
|
||||
moveHLSFiles: (video: MVideoWithAllFiles) => Promise<void>
|
||||
moveVideoSourceFile: (source: MVideoSource) => Promise<void>
|
||||
moveCaptionFiles: (captions: MVideoCaption[]) => Promise<void>
|
||||
moveCaptionFiles: (captions: MVideoCaption[], hls: MStreamingPlaylistVideoUUID) => Promise<void>
|
||||
|
||||
moveToFailedState: (video: MVideoWithAllFiles) => Promise<void>
|
||||
doAfterLastMove: (video: MVideoWithAllFiles) => Promise<void>
|
||||
|
@ -68,9 +68,10 @@ export async function moveVideoToStorageJob (options: {
|
|||
|
||||
const captions = await VideoCaptionModel.listVideoCaptions(video.id)
|
||||
if (captions.length !== 0) {
|
||||
logger.debug(`Moving captions of ${video.uuid}.`, lTags)
|
||||
logger.debug(`Moving ${captions.length} captions of ${video.uuid}.`, lTags)
|
||||
|
||||
await moveCaptionFiles(captions)
|
||||
const hls = video.getHLSPlaylist()
|
||||
await moveCaptionFiles(captions, hls)
|
||||
}
|
||||
|
||||
const pendingMove = await VideoJobInfoModel.decrease(video.uuid, 'pendingMove')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue