ffmpeg exits on '-tag:v hvc1' when video stream is copied but not HEVC encoded #2766

Closed
opened 2026-02-05 07:01:15 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @Harry-Chen on GitHub (Apr 6, 2024).

The bug

In getBaseOutputOptions function, -tag:v hvc1 is passed to ffmpeg when target video codec is HEVC. However, when other video codec (e.g. H.264) is accepted (thus -c:v copy is used), ffmepg will report an error on incompatible tag.

56d27bc1b4/server/src/utils/media.ts (L64-L66)

Excerpted logs:

[Nest] 7  - 04/06/2024, 2:12:37 PM     LOG [MediaService] Started encoding video e0598297-989f-417c-8131-1261a9dd2f11 {"inputOptions":["-init_hw_device qsv=hw","-filter_hw_device hw"],"outputOptions":["-c:v copy","-c:a aac","-movflags faststart","-fps_mode passthrough","-map 0:0","-map 0:1","-bf 7","-refs 5","-g 256","-tag:v hvc1","-v verbose","-preset 7","-global_quality 23"],"twoPass":false}
[Nest] 7  - 04/06/2024, 2:12:37 PM   ERROR [MediaRepository] ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers

...(omitted)...

[mp4 @ 0x57d701ccc00] Tag hvc1 incompatible with output codec id '27' (avc1)
[out#0/mp4 @ 0x57d701f1d40] Could not write header (incorrect codec parameters ?): Invalid data found when processing input
[aost#0:1/aac @ 0x57d701d6180] Error initializing output stream: 
[aac @ 0x57d70213580] Qavg: nan
[AVIOContext @ 0x57d70205400] Statistics: 0 bytes written, 0 seeks, 0 writeouts
Terminating demuxer thread 0
[AVIOContext @ 0x57d70204f00] Statistics: 648760 bytes read, 5 seeks
Conversion failed!

[Nest] 7  - 04/06/2024, 2:12:37 PM   ERROR [MediaService] Error: ffmpeg exited with code 1: Conversion failed!

The OS that Immich Server is running on

Docker on Debian

Version of Immich Server

v1.101.0

Version of Immich Mobile App

N/A

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

Not relevant

Your .env content

Not relevant

Reproduction steps

Set VIDEO CODEC to hevc, and set ACCEPTED VIDEO CODECS to H.264 + HEVC. When encountering a file with any unsupported audio codec (e.g. PCM), Immich will try to transcode and fail.

Additional information

No response

Originally created by @Harry-Chen on GitHub (Apr 6, 2024). ### The bug In `getBaseOutputOptions` function, `-tag:v hvc1` is passed to ffmpeg when target video codec is HEVC. However, when other video codec (e.g. H.264) is accepted (thus `-c:v copy` is used), ffmepg will report an error on incompatible tag. https://github.com/immich-app/immich/blob/56d27bc1b45abcbd092e7df7d25d27492828c0dc/server/src/utils/media.ts#L64-L66 Excerpted logs: ```text [Nest] 7 - 04/06/2024, 2:12:37 PM LOG [MediaService] Started encoding video e0598297-989f-417c-8131-1261a9dd2f11 {"inputOptions":["-init_hw_device qsv=hw","-filter_hw_device hw"],"outputOptions":["-c:v copy","-c:a aac","-movflags faststart","-fps_mode passthrough","-map 0:0","-map 0:1","-bf 7","-refs 5","-g 256","-tag:v hvc1","-v verbose","-preset 7","-global_quality 23"],"twoPass":false} [Nest] 7 - 04/06/2024, 2:12:37 PM ERROR [MediaRepository] ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers ...(omitted)... [mp4 @ 0x57d701ccc00] Tag hvc1 incompatible with output codec id '27' (avc1) [out#0/mp4 @ 0x57d701f1d40] Could not write header (incorrect codec parameters ?): Invalid data found when processing input [aost#0:1/aac @ 0x57d701d6180] Error initializing output stream: [aac @ 0x57d70213580] Qavg: nan [AVIOContext @ 0x57d70205400] Statistics: 0 bytes written, 0 seeks, 0 writeouts Terminating demuxer thread 0 [AVIOContext @ 0x57d70204f00] Statistics: 648760 bytes read, 5 seeks Conversion failed! [Nest] 7 - 04/06/2024, 2:12:37 PM ERROR [MediaService] Error: ffmpeg exited with code 1: Conversion failed! ``` ### The OS that Immich Server is running on Docker on Debian ### Version of Immich Server v1.101.0 ### Version of Immich Mobile App N/A ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML Not relevant ``` ### Your .env content ```Shell Not relevant ``` ### Reproduction steps ```bash Set VIDEO CODEC to hevc, and set ACCEPTED VIDEO CODECS to H.264 + HEVC. When encountering a file with any unsupported audio codec (e.g. PCM), Immich will try to transcode and fail. ``` ### Additional information _No response_
OVERLORD added the 🗄️serverformat labels 2026-02-05 07:01:15 +03:00
Author
Owner

@mertalev commented on GitHub (Apr 7, 2024):

Thanks for the very detailed issue! This is definitely an oversight.

@mertalev commented on GitHub (Apr 7, 2024): Thanks for the very detailed issue! This is definitely an oversight.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#2766