Prevent HLS transcoding after webtorrent transcoding

pull/4765/head
Chocobozzz 2022-02-01 11:16:45 +01:00
parent 3e8c3fcdb0
commit 0f11ec8dd3
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 42 additions and 9 deletions

View File

@ -77,6 +77,8 @@ async function run () {
type: 'new-resolution-to-webtorrent',
videoUUID: video.uuid,
createHLSIfNeeded: true,
// FIXME: check the file has audio
hasAudio: true,

View File

@ -25,7 +25,7 @@ export {
async function createTranscoding (req: express.Request, res: express.Response) {
const video = res.locals.videoAll
logger.info('Creating %s transcoding job for %s.', req.body.type, video.url, lTags())
logger.info('Creating %s transcoding job for %s.', req.body.transcodingType, video.url, lTags())
const body: VideoTranscodingCreate = req.body
@ -53,8 +53,9 @@ async function createTranscoding (req: express.Request, res: express.Response) {
type: 'new-resolution-to-webtorrent',
videoUUID: video.uuid,
isNewVideo: false,
resolution: resolution,
resolution,
hasAudio: !!audioStream,
createHLSIfNeeded: false,
isPortraitMode
})
}

View File

@ -10,7 +10,7 @@ import { pick } from '@shared/core-utils'
import {
HLSTranscodingPayload,
MergeAudioTranscodingPayload,
NewResolutionTranscodingPayload,
NewWebTorrentResolutionTranscodingPayload,
OptimizeTranscodingPayload,
VideoResolution,
VideoTranscodingPayload
@ -110,7 +110,7 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MV
async function handleNewWebTorrentResolutionJob (
job: Job,
payload: NewResolutionTranscodingPayload,
payload: NewWebTorrentResolutionTranscodingPayload,
video: MVideoFullLight,
user: MUserId
) {
@ -217,9 +217,12 @@ async function onVideoFirstWebTorrentTranscoding (
async function onNewWebTorrentFileResolution (
video: MVideo,
user: MUserId,
payload: NewResolutionTranscodingPayload | MergeAudioTranscodingPayload
payload: NewWebTorrentResolutionTranscodingPayload | MergeAudioTranscodingPayload
) {
await createHlsJobIfEnabled(user, { hasAudio: true, copyCodecs: true, isMaxQuality: false, ...payload })
if (payload.createHLSIfNeeded) {
await createHlsJobIfEnabled(user, { hasAudio: true, copyCodecs: true, isMaxQuality: false, ...payload })
}
await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
@ -282,6 +285,7 @@ async function createLowerResolutionsJobs (options: {
resolution,
isPortraitMode,
hasAudio,
createHLSIfNeeded: true,
isNewVideo
}

View File

@ -89,6 +89,7 @@ async function addOptimizeOrMergeAudioJob (video: MVideoUUID, videoFile: MVideoF
type: 'merge-audio-to-webtorrent',
resolution: DEFAULT_AUDIO_RESOLUTION,
videoUUID: video.uuid,
createHLSIfNeeded: true,
isNewVideo: true
}
} else {

View File

@ -25,7 +25,11 @@ async function checkFilesInObjectStorage (video: VideoDetails) {
await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
}
for (const file of video.streamingPlaylists[0].files) {
const streamingPlaylistFiles = video.streamingPlaylists.length === 0
? []
: video.streamingPlaylists[0].files
for (const file of streamingPlaylistFiles) {
expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
}
@ -127,6 +131,25 @@ function runTests (objectStorage: boolean) {
}
})
it('Should only generate WebTorrent', async function () {
this.timeout(60000)
await servers[0].videos.removeHLSFiles({ videoId: videoUUID })
await waitJobs(servers)
await servers[0].videos.runTranscoding({ videoId: videoUUID, transcodingType: 'webtorrent' })
await waitJobs(servers)
for (const server of servers) {
const videoDetails = await server.videos.get({ id: videoUUID })
expect(videoDetails.files).to.have.lengthOf(5)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
if (objectStorage) await checkFilesInObjectStorage(videoDetails)
}
})
it('Should not have updated published at attributes', async function () {
const video = await servers[0].videos.get({ id: videoUUID })

View File

@ -113,11 +113,12 @@ export interface HLSTranscodingPayload extends BaseTranscodingPayload {
isMaxQuality: boolean
}
export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload {
export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
type: 'new-resolution-to-webtorrent'
resolution: VideoResolution
hasAudio: boolean
createHLSIfNeeded: boolean
isPortraitMode?: boolean
}
@ -125,6 +126,7 @@ export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload
export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
type: 'merge-audio-to-webtorrent'
resolution: VideoResolution
createHLSIfNeeded: true
}
export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
@ -133,7 +135,7 @@ export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
export type VideoTranscodingPayload =
HLSTranscodingPayload
| NewResolutionTranscodingPayload
| NewWebTorrentResolutionTranscodingPayload
| OptimizeTranscodingPayload
| MergeAudioTranscodingPayload