Skip to content

High performance self-hosted photo and video management solution.

fix(server): HEVC videos not playing on Apple devices (#6712)

Merte5a70329c920
diff --git a/server/src/domain/media/media.service.spec.ts b/server/src/domain/media/media.service.spec.ts
index 7f56501011..d76a793178 100644
--- a/server/src/domain/media/media.service.spec.ts
+++ b/server/src/domain/media/media.service.spec.ts
@@ -1094,6 +1094,7 @@ describe(MediaService.name, () => {
'-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
+ '-tag:v hvc1',
'-v verbose',
'-vf scale=-2:720,format=yuv420p',
'-preset ultrafast',
@@ -1127,6 +1128,7 @@ describe(MediaService.name, () => {
'-fps_mode passthrough',
'-map 0:0',
'-map 0:1',
+ '-tag:v hvc1',
'-v verbose',
'-vf scale=-2:720,format=yuv420p',
'-preset ultrafast',
@@ -1673,6 +1675,7 @@ describe(MediaService.name, () => {
'-map 0:0',
'-map 0:1',
'-g 256',
+ '-tag:v hvc1',
'-v verbose',
'-level 153',
'-rc_mode 3',
diff --git a/server/src/domain/media/media.util.ts b/server/src/domain/media/media.util.ts
index 606cb3f1a1..6741be5df4 100644
--- a/server/src/domain/media/media.util.ts
+++ b/server/src/domain/media/media.util.ts
@@ -44,6 +44,7 @@ class BaseConfig implements VideoCodecSWConfig {
// explicitly selects the video stream instead of leaving it up to FFmpeg
`-map 0:${videoStream.index}`,
];
+
if (audioStream) {
options.push(`-map 0:${audioStream.index}`);
}
@@ -56,6 +57,11 @@ class BaseConfig implements VideoCodecSWConfig {
if (this.getGopSize() > 0) {
options.push(`-g ${this.getGopSize()}`);
}
+
+ if (this.config.targetVideoCodec === VideoCodec.HEVC) {
+ options.push('-tag:v hvc1');
+ }
+
return options;
}