Skip to content

High performance self-hosted photo and video management solution.

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

Mertf9671dfbf75a
diff --git a/server/src/domain/media/media.service.spec.ts b/server/src/domain/media/media.service.spec.ts
index 616debedee..010e68a23b 100644
--- a/server/src/domain/media/media.service.spec.ts
+++ b/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',
diff --git a/server/src/domain/media/media.service.ts b/server/src/domain/media/media.service.ts
index 50f49032ca..7dedc6a056 100644
--- a/server/src/domain/media/media.service.ts
+++ b/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