Pārlūkot izejas kodu

fix(server): h264 videos failing to transcode in two-pass mode (#3053)

* set `-fps_mode` to passthrough

* updated tests
Mert 2 gadi atpakaļ
vecāks
revīzija
f9671dfbf7

+ 34 - 3
server/src/domain/media/media.service.spec.ts

@@ -232,7 +232,14 @@ describe(MediaService.name, () => {
         '/original/path.ext',
         'upload/encoded-video/user-id/asset-id.mp4',
         {
-          outputOptions: ['-vcodec h264', '-acodec aac', '-movflags faststart', '-preset ultrafast', '-crf 23'],
+          outputOptions: [
+            '-vcodec h264',
+            '-acodec aac',
+            '-movflags faststart',
+            '-fps_mode passthrough',
+            '-preset ultrafast',
+            '-crf 23',
+          ],
           twoPass: false,
         },
       );
@@ -261,7 +268,14 @@ describe(MediaService.name, () => {
         '/original/path.ext',
         'upload/encoded-video/user-id/asset-id.mp4',
         {
-          outputOptions: ['-vcodec h264', '-acodec aac', '-movflags faststart', '-preset ultrafast', '-crf 23'],
+          outputOptions: [
+            '-vcodec h264',
+            '-acodec aac',
+            '-movflags faststart',
+            '-fps_mode passthrough',
+            '-preset ultrafast',
+            '-crf 23',
+          ],
           twoPass: false,
         },
       );
@@ -279,6 +293,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-crf 23',
@@ -299,7 +314,14 @@ describe(MediaService.name, () => {
         '/original/path.ext',
         'upload/encoded-video/user-id/asset-id.mp4',
         {
-          outputOptions: ['-vcodec h264', '-acodec aac', '-movflags faststart', '-preset ultrafast', '-crf 23'],
+          outputOptions: [
+            '-vcodec h264',
+            '-acodec aac',
+            '-movflags faststart',
+            '-fps_mode passthrough',
+            '-preset ultrafast',
+            '-crf 23',
+          ],
           twoPass: false,
         },
       );
@@ -318,6 +340,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=720:-2',
             '-preset ultrafast',
             '-crf 23',
@@ -340,6 +363,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-crf 23',
@@ -362,6 +386,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-crf 23',
@@ -392,6 +417,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-crf 23',
@@ -419,6 +445,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-b:v 3104k',
@@ -443,6 +470,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-crf 23',
@@ -468,6 +496,7 @@ describe(MediaService.name, () => {
             '-vcodec vp9',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-cpu-used 5',
             '-row-mt 1',
@@ -496,6 +525,7 @@ describe(MediaService.name, () => {
             '-vcodec vp9',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-cpu-used 5',
             '-row-mt 1',
@@ -521,6 +551,7 @@ describe(MediaService.name, () => {
             '-vcodec h264',
             '-acodec aac',
             '-movflags faststart',
+            '-fps_mode passthrough',
             '-vf scale=-2:720',
             '-preset ultrafast',
             '-threads 2',

+ 2 - 1
server/src/domain/media/media.service.ts

@@ -222,7 +222,8 @@ export class MediaService {
       `-acodec ${ffmpeg.targetAudioCodec}`,
       // Makes a second pass moving the moov atom to the beginning of
       // the file for improved playback speed.
-      `-movflags faststart`,
+      '-movflags faststart',
+      '-fps_mode passthrough',
     ];
 
     // video dimensions