immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
38.87k stars 1.83k forks source link

Recoded video - rotation wrong #10498

Open Str1atum opened 2 weeks ago

Str1atum commented 2 weeks ago

The bug

With 1.106.4 if have an issue with the recoded videos being the wrong orientation. It affects HEVC encoded videos in 1080p or 4k from iPhone 13 and 15. Videos in portrait orientation are rotated to landscape. Videos in landscape are rotated 180°. The videos do not just play that way in the browser but also when I download the recoded videos with Chrome to my local disk.

recode config is:

"ffmpeg": { "crf": 28, "threads": 0, "preset": "medium", "targetVideoCodec": "hevc", "acceptedVideoCodecs": [ "hevc" ], "targetAudioCodec": "aac", "acceptedAudioCodecs": [ "libopus", "mp3", "aac" ], "targetResolution": "720", "maxBitrate": "2500", "bframes": -1, "refs": 0, "gopSize": 0, "npl": 0, "temporalAQ": false, "cqMode": "auto", "twoPass": true, "preferredHwDevice": "auto", "transcode": "required", "tonemap": "hable", "accel": "qsv", "accelDecode": true

The OS that Immich Server is running on

Ubunti 24.04

Version of Immich Server

1.106.4

Version of Immich Mobile App

v.106

Platform with the issue

Your docker-compose.yml content

default

Your .env content

default

Reproduction steps

see above

Relevant log output

No response

Additional information

No response

Str1atum commented 2 weeks ago

log output of two sample videos:

[Nest] 7 - 06/20/2024, 8:34:15 AM  LOG [Microservices:MediaService] Started encoding video 196cae26-f6d7-43c0-afae-37a7f88864db {"inputOptions":["-hwaccel qsv","-hwaccel_output_format qsv","-async_depth 4","-threads 1"],"outputOptions":["-c:v hevc_qsv","-c:a copy","-movflags faststart","-fps_mode passthrough","-map 0:0","-map 0:1","-bf 7","-refs 5","-g 256","-tag:v hvc1","-v verbose","-vf scale_qsv=720:-1:async_depth=4:mode=hq,hwmap=derive_device=opencl,tonemap_opencl=desat=0:format=nv12:matrix=bt709:primaries=bt709:range=pc:tonemap=hable:transfer=bt709,hwmap=derive_device=qsv:reverse=1,format=qsv","-preset 4","-global_quality:v 28","-maxrate 2500","-bufsize 5000"],"twoPass":false}

[Nest] 7 - 06/20/2024, 8:34:16 AM  LOG [Microservices:MediaService] Successfully encoded 196cae26-f6d7-43c0-afae-37a7f88864db

[Nest] 7 - 06/20/2024, 8:34:16 AM  LOG [Microservices:MediaService] Started encoding video 9fcbe395-fc0d-4933-8248-6d582fd6e255 {"inputOptions":["-hwaccel qsv","-hwaccel_output_format qsv","-async_depth 4","-threads 1"],"outputOptions":["-c:v hevc_qsv","-c:a copy","-movflags faststart","-fps_mode passthrough","-map 0:0","-map 0:1","-bf 7","-refs 5","-g 256","-tag:v hvc1","-v verbose","-vf scale_qsv=-1:720:async_depth=4:mode=hq,hwmap=derive_device=opencl,tonemap_opencl=desat=0:format=nv12:matrix=bt709:primaries=bt709:range=pc:tonemap=hable:transfer=bt709,hwmap=derive_device=qsv:reverse=1,format=qsv","-preset 4","-global_quality:v 28","-maxrate 2500","-bufsize 5000"],"twoPass":false}

[Nest] 7 - 06/20/2024, 8:34:18 AM  LOG [Microservices:MediaService] Successfully encoded 9fcbe395-fc0d-4933-8248-6d582fd6e255