Intel QSV: Portrait Live Photos transcoded in avc codec are in landscape #2176

Closed
opened 2026-02-20 01:07:31 -05:00 by deekerman · 4 comments
Owner

Originally created by @MertDalbudak on GitHub (Sep 5, 2024).

Live Photos taken on an iPhone Xr that are recorded in portrait mode and transcoded to avc are in landscape mode. Chrome useses the hevc codec video which plays the Live Photos in the correct orientation. Firefox however plays the avc codec video which makes the Live Photo played in a incorrect orientation.

However actual Videos that have been recorded on the iPhone in portrait mode are also transcoded in a landscape video in hevc.

Here is a example of an Live Photo:

Screenshot 2024-09-05 141248

Screenshot 2024-09-05 141326

FFMPEG Intel GPU Hardware support enabled (UHD Graphics 630)
Photoprism runs inside a Podman container

Version: Build 240711-2197af848

Originally created by @MertDalbudak on GitHub (Sep 5, 2024). Live Photos taken on an iPhone Xr that are recorded in portrait mode and transcoded to avc are in landscape mode. Chrome useses the hevc codec video which plays the Live Photos in the correct orientation. Firefox however plays the avc codec video which makes the Live Photo played in a incorrect orientation. ### However actual Videos that have been recorded on the iPhone in portrait mode are also transcoded in a landscape video in hevc. Here is a example of an Live Photo: ![Screenshot 2024-09-05 141248](https://github.com/user-attachments/assets/feda2811-7943-4479-8350-4ea56bad1849) ![Screenshot 2024-09-05 141326](https://github.com/user-attachments/assets/540a5a4f-787c-4f28-b971-df983947feb9) FFMPEG Intel GPU Hardware support enabled (UHD Graphics 630) Photoprism runs inside a Podman container Version: Build 240711-2197af848
Author
Owner

@lastzero commented on GitHub (Sep 5, 2024):

This is an upstream issue with FFmpeg and Intel hardware transcoding. It has already been discussed in a number of places. Since I'm on my phone, I can't provide you with links but switching to software transcoding (or Nvidia) should work based on the feedback we have received.

@lastzero commented on GitHub (Sep 5, 2024): This is an upstream issue with FFmpeg and Intel hardware transcoding. It has already been discussed in a number of places. Since I'm on my phone, I can't provide you with links but switching to software transcoding (or Nvidia) should work based on the feedback we have received.
Author
Owner

@lastzero commented on GitHub (Sep 5, 2024):

Here's the original report:

@lastzero commented on GitHub (Sep 5, 2024): Here's the original report: - https://github.com/photoprism/photoprism/issues/4403
Author
Owner

@MertDalbudak commented on GitHub (Sep 6, 2024):

This is an upstream issue with FFmpeg and Intel hardware transcoding. It has already been discussed in a number of places. Since I'm on my phone, I can't provide you with links but switching to software transcoding (or Nvidia) should work based on the feedback we have received.

I cannot use nvidia because I do not have a nvidia gpu. Software trasncoding takes tremendous amout of time to render and also uses a lot of memory in the process.

Based on the ffmpeg documentation we might solve the issue by adding -noautorotate as an option for QSV transcoding.

internal/ffmpeg/convert.go

case IntelEncoder:
    // ffmpeg -hide_banner -h encoder=h264_qsv
    result = exec.Command(
        ffmpeg,
        "-hwaccel", "qsv",
        "-hwaccel_output_format", "qsv",
        "-qsv_device", "/dev/dri/renderD128",
        "-i", fileName,
        "-c:a", "aac",
        "-vf", opt.VideoFilter(FormatQSV),
        "-c:v", opt.Encoder.String(),
        "-map", opt.MapVideo,
        "-map", opt.MapAudio,
        "-r", "30",
        "-b:v", opt.Bitrate,
        "-bitrate", opt.Bitrate,
        "-f", "mp4",
        "-movflags", "+faststart", // puts headers at the beginning for faster streaming
        "-y",
        avcName,
        noautorotate
    )
@MertDalbudak commented on GitHub (Sep 6, 2024): > This is an upstream issue with FFmpeg and Intel hardware transcoding. It has already been discussed in a number of places. Since I'm on my phone, I can't provide you with links but switching to software transcoding (or Nvidia) should work based on the feedback we have received. I cannot use nvidia because I do not have a nvidia gpu. Software trasncoding takes tremendous amout of time to render and also uses a lot of memory in the process. Based on the [ffmpeg documentation](https://www.ffmpeg.org/ffmpeg.html#Video-Options) we might solve the issue by adding `-noautorotate` as an option for QSV transcoding. ### internal/ffmpeg/[convert.go](https://github.com/photoprism/photoprism/blob/98b0dc5e07ac80fe83b439478fe767f4760bc01a/internal/ffmpeg/convert.go) ``` case IntelEncoder: // ffmpeg -hide_banner -h encoder=h264_qsv result = exec.Command( ffmpeg, "-hwaccel", "qsv", "-hwaccel_output_format", "qsv", "-qsv_device", "/dev/dri/renderD128", "-i", fileName, "-c:a", "aac", "-vf", opt.VideoFilter(FormatQSV), "-c:v", opt.Encoder.String(), "-map", opt.MapVideo, "-map", opt.MapAudio, "-r", "30", "-b:v", opt.Bitrate, "-bitrate", opt.Bitrate, "-f", "mp4", "-movflags", "+faststart", // puts headers at the beginning for faster streaming "-y", avcName, noautorotate ) ```
Author
Owner

@lastzero commented on GitHub (Sep 6, 2024):

I have already tried this. You are welcome to repeat the tests and let us know if you were successful.

@lastzero commented on GitHub (Sep 6, 2024): I have already tried this. You are welcome to repeat the tests and let us know if you were successful.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#2176
No description provided.