]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Reload the video after waiting for the files lock
authorChocobozzz <me@florianbigard.com>
Fri, 5 May 2023 11:41:48 +0000 (13:41 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Tue, 9 May 2023 06:57:34 +0000 (08:57 +0200)
server/lib/job-queue/handlers/manage-video-torrent.ts
server/lib/job-queue/handlers/move-to-object-storage.ts
server/lib/job-queue/handlers/video-live-ending.ts
server/lib/transcoding/hls-transcoding.ts
server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts
server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts
server/tests/peertube-runner/live-transcoding.ts
server/tests/peertube-runner/studio-transcoding.ts
server/tests/peertube-runner/vod-transcoding.ts
shared/server-commands/videos/live.ts

index cef93afda011cfd932df166112272a20817b7970..edf52de0cc325c27dd028ae3f972023cc8853496 100644 (file)
@@ -35,6 +35,9 @@ async function doCreateAction (payload: ManageVideoTorrentPayload & { action: 'c
   const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
 
   try {
+    await video.reload()
+    await file.reload()
+
     await createTorrentAndSetInfoHash(video, file)
 
     // Refresh videoFile because the createTorrentAndSetInfoHash could be long
index a1530cc573daaf3415da380c4dec199b2ec17fbd..26752ff37def714f1713453eb5c8288f7deb6382 100644 (file)
@@ -19,17 +19,18 @@ export async function processMoveToObjectStorage (job: Job) {
   const payload = job.data as MoveObjectStoragePayload
   logger.info('Moving video %s in job %s.', payload.videoUUID, job.id)
 
+  const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(payload.videoUUID)
+
   const video = await VideoModel.loadWithFiles(payload.videoUUID)
   // No video, maybe deleted?
   if (!video) {
     logger.info('Can\'t process job %d, video does not exist.', job.id, lTagsBase(payload.videoUUID))
+    fileMutexReleaser()
     return undefined
   }
 
   const lTags = lTagsBase(video.uuid, video.url)
 
-  const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
-
   try {
     if (video.VideoFiles) {
       logger.debug('Moving %d webtorrent files for video %s.', video.VideoFiles.length, video.uuid, lTags)
index 1bf43f5928c1727dab769556262ec58b48642042..814f313a3bb8d946905bbbce3fb1ffba571e0d28 100644 (file)
@@ -218,6 +218,7 @@ async function assignReplayFilesToVideo (options: {
 
   for (const concatenatedTsFile of concatenatedTsFiles) {
     const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
+    await video.reload()
 
     const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile)
 
index cffa859c7cf8940b0dde6ee1c707f8798678d64d..2c325d9ee0b2dd0a7734138fe84943351f37e330 100644 (file)
@@ -72,7 +72,6 @@ export async function onHLSVideoFileTranscoding (options: {
   const mutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
 
   try {
-    // VOD transcoding is a long task, refresh video attributes
     await video.reload()
 
     const videoFilePath = VideoPathManager.Instance.getFSVideoFileOutputPath(playlist, videoFile)
index 29ee2ca61fe28afd6ae887dfab910f290c89b8df..fa2ac70bf1d1646c978e657fdb6fe438d464d001 100644 (file)
@@ -40,6 +40,9 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
       : await VideoPathManager.Instance.lockFiles(video.uuid)
 
     try {
+      await video.reload()
+      await videoFile.reload()
+
       await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => {
         const probe = await ffprobePromise(videoFilePath)
 
index 90b035402053fbea52c5a64c65183b21865229d2..4b8bc2f3de92ca46e47678e094e73e759db983e6 100644 (file)
@@ -36,6 +36,9 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
       : await VideoPathManager.Instance.lockFiles(video.uuid)
 
     try {
+      await video.reload()
+      await videoFile.reload()
+
       await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => {
         const probe = await ffprobePromise(videoFilePath)
 
index 31716d54539b1da6f5278b3ed7dd3f6c3a7f1690..f0acf25c8b07c78888a087e659efc64632f7afb0 100644 (file)
@@ -183,8 +183,10 @@ describe('Test Live transcoding in peertube-runner program', function () {
   })
 
   after(async function () {
-    await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
-    peertubeRunner.kill()
+    if (peertubeRunner) {
+      await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
+      peertubeRunner.kill()
+    }
 
     await cleanupTests(servers)
   })
index 204836c4d45e7958cdc49c03267be897d4fafb45..e20cc90414d27366fa3249f31203bcb982737c27 100644 (file)
@@ -108,8 +108,10 @@ describe('Test studio transcoding in peertube-runner program', function () {
   })
 
   after(async function () {
-    await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
-    peertubeRunner.kill()
+    if (peertubeRunner) {
+      await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
+      peertubeRunner.kill()
+    }
 
     await cleanupTests(servers)
   })
index 3a9abba93e730b1d14e50be9f8ef514177997133..3c09181029d342cec088195ec24ab181a110e264 100644 (file)
@@ -334,8 +334,10 @@ describe('Test VOD transcoding in peertube-runner program', function () {
   })
 
   after(async function () {
-    await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
-    peertubeRunner.kill()
+    if (peertubeRunner) {
+      await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
+      peertubeRunner.kill()
+    }
 
     await cleanupTests(servers)
   })
index 578e6ede78d5c400651c29532339f68c74ca908c..3b09d3ff81c9ef01003109cbdd3f9d1431555f1d 100644 (file)
@@ -21,8 +21,8 @@ function sendRTMPStream (options: {
     command.outputOption('-c copy')
   } else {
     command.outputOption('-c:v libx264')
-    command.outputOption('-g 50')
-    command.outputOption('-keyint_min 2')
+    command.outputOption('-g 120')
+    command.outputOption('-x264-params "no-scenecut=1"')
     command.outputOption('-r 60')
   }