[BUG] Transcodes fail for 4k videos captured on Android with Store Videos Efficiently setting enabled #1028

Closed
opened 2026-02-05 00:06:17 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @mertalev on GitHub (Jun 28, 2023).

The bug

The Store Videos Efficiently feature was introduced in Android 12 and is enabled by default on Google Pixel phones. In this setting, videos are stored as HEVC instead of H.264 and have an additional MetaHandle stream. ffprobe struggles to interpret these videos and fails with a moov atom not found error, particularly on 4K videos.

However, it is still possible for it to successfully transcode if the video is uploaded right after recording. In this case it does not raise an error, only warning Unsupported codec with id 0 for input stream 0 (referring to MetaHandle), and ffmpeg is able to transcode the video successfully.

Possible resolutions:

  • Use the Compatible Media Transcoding API. Apps that request this setting can have HEVC videos transcoded to H.264 on the phone itself.
    • However, there is a default video length limit of 1 minute. This can be overridden, but it suggests that it may be a suboptimal solution for longer videos.
  • Diagnose this error further and find a way to reliably transcode these videos in the server.
  • Have users disable this setting. Note that even when disabled, videos already recorded will still be stored as HEVC.

The OS that Immich Server is running on

Version of Immich Server

v1.63.2

Version of Immich Mobile App

v1.63.0

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

-

Your .env content

-

Reproduction steps

1. Enable `Store Videos Efficiently` on an Android phone running Android 12 or above.
2. Enable transcoding with the target video codec set to `h264` and resolution set to `1080p`.
3. Record a 4K video.
4. (optional) Wait for some time; behavior may differ between videos uploaded immediately and those that have existed for a period of time.
5. Upload it to the server.
6. Check the logs of `immich_microservices` to see whether transcoding succeeded.

Additional information

There are similar issues posted online concerning ffmpeg's handling of these videos, including here, here and here.

Originally created by @mertalev on GitHub (Jun 28, 2023). ### The bug The Store Videos Efficiently feature was introduced in Android 12 and is enabled by default on Google Pixel phones. In this setting, videos are stored as HEVC instead of H.264 and have an additional `MetaHandle` stream. `ffprobe` struggles to interpret these videos and fails with a `moov atom not found` error, particularly on 4K videos. However, it is still possible for it to successfully transcode if the video is uploaded right after recording. In this case it does not raise an error, only warning `Unsupported codec with id 0 for input stream 0` (referring to `MetaHandle`), and `ffmpeg` is able to transcode the video successfully. ### Possible resolutions: * Use the [Compatible Media Transcoding API](https://source.android.com/docs/core/media/media-transcoding). Apps that request this setting can have HEVC videos transcoded to H.264 on the phone itself. - However, there is a default video length limit of 1 minute. This can be overridden, but it suggests that it may be a suboptimal solution for longer videos. * Diagnose this error further and find a way to reliably transcode these videos in the server. - Have users disable this setting. Note that even when disabled, videos already recorded will still be stored as HEVC. ### The OS that Immich Server is running on - ### Version of Immich Server v1.63.2 ### Version of Immich Mobile App v1.63.0 ### Platform with the issue - [X] Server - [ ] Web - [X] Mobile ### Your docker-compose.yml content ```YAML - ``` ### Your .env content ```Shell - ``` ### Reproduction steps ```bash 1. Enable `Store Videos Efficiently` on an Android phone running Android 12 or above. 2. Enable transcoding with the target video codec set to `h264` and resolution set to `1080p`. 3. Record a 4K video. 4. (optional) Wait for some time; behavior may differ between videos uploaded immediately and those that have existed for a period of time. 5. Upload it to the server. 6. Check the logs of `immich_microservices` to see whether transcoding succeeded. ``` ### Additional information There are similar issues posted online concerning ffmpeg's handling of these videos, including [here](https://stackoverflow.com/questions/75751218/using-ffmpeg-to-read-mp4-file-from-stdin-and-extract-image-is-failing-with-inva), [here](https://github.com/caydey/ffshare/issues/22) and [here](https://github.com/jellyfin/jellyfin/issues/8306).
OVERLORD added the 🗄️server label 2026-02-05 00:06:17 +03:00
Author
Owner

@kt368 commented on GitHub (Jan 4, 2024):

I'm having the same problem. Google Pixel 7. When h.265 is specified in the camera settings, videos are not transcoded with Immich. If I switch to the h.264 - transcoding start to work for the new videos.

@kt368 commented on GitHub (Jan 4, 2024): I'm having the same problem. Google Pixel 7. When h.265 is specified in the camera settings, videos are not transcoded with Immich. If I switch to the h.264 - transcoding start to work for the new videos.
Author
Owner

@bshor commented on GitHub (Apr 2, 2024):

Same problem on Pixel 7 1080p/30. Whether or not I have HEVC selected.

The only solution is selecting 60fps AND no HEVC.

@bshor commented on GitHub (Apr 2, 2024): Same problem on Pixel 7 1080p/30. Whether or not I have HEVC selected. The only solution is selecting 60fps AND no HEVC.
Author
Owner

@jrasm91 commented on GitHub (Sep 4, 2024):

@mertalev is this still an issue?

@jrasm91 commented on GitHub (Sep 4, 2024): @mertalev is this still an issue?
Author
Owner

@mertalev commented on GitHub (Sep 4, 2024):

I didn't make any transcoding changes to fix this, but not sure if it got indirectly fixed. You have a Pixel, right? Try reproducing the steps in the issue.

@mertalev commented on GitHub (Sep 4, 2024): I didn't make any transcoding changes to fix this, but not sure if it got indirectly fixed. You have a Pixel, right? Try reproducing the steps in the issue.
Author
Owner

@jrasm91 commented on GitHub (Sep 4, 2024):

I turned the setting on last night. Then it uploaded today. I see this in the logs:

immich_server            | [Nest] 7  - 09/04/2024, 1:33:58 PM     LOG [Microservices:MediaService] Started encoding video 4d64ae1a-a3aa-43b1-9cae-ae8fa56cb786 {"inputOptions":[],"outputOptions":["-c:v h264","-c:a copy","-movflags faststart","-fps_mode passthrough","-map 0:2","-map 0:1","-v verbose","-vf scale=720:-2,format=yuv420p","-preset ultrafast","-crf 23"],"twoPass":false}
immich_server            | [Nest] 7  - 09/04/2024, 1:33:59 PM     LOG [Microservices:MediaService] Successfully encoded 4d64ae1a-a3aa-43b1-9cae-ae8fa56cb786

And VLC shows this information for the original asset:

image

As far as I can tell this is a H.265/HEVC and it was correctly converted to H.264.

@jrasm91 commented on GitHub (Sep 4, 2024): I turned the setting on last night. Then it uploaded today. I see this in the logs: ``` immich_server | [Nest] 7 - 09/04/2024, 1:33:58 PM LOG [Microservices:MediaService] Started encoding video 4d64ae1a-a3aa-43b1-9cae-ae8fa56cb786 {"inputOptions":[],"outputOptions":["-c:v h264","-c:a copy","-movflags faststart","-fps_mode passthrough","-map 0:2","-map 0:1","-v verbose","-vf scale=720:-2,format=yuv420p","-preset ultrafast","-crf 23"],"twoPass":false} immich_server | [Nest] 7 - 09/04/2024, 1:33:59 PM LOG [Microservices:MediaService] Successfully encoded 4d64ae1a-a3aa-43b1-9cae-ae8fa56cb786 ``` And VLC shows this information for the original asset: ![image](https://github.com/user-attachments/assets/39a11b9e-5c4f-4e7e-8236-648763d21434) As far as I can tell this is a H.265/HEVC and it was correctly converted to H.264.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1028