Skip to content

Prevent FFmpeg errors when generating thumbnails for videos with multiple video streams.#28162

Open
pinhao wants to merge 2 commits intoimmich-app:mainfrom
pinhao:main
Open

Prevent FFmpeg errors when generating thumbnails for videos with multiple video streams.#28162
pinhao wants to merge 2 commits intoimmich-app:mainfrom
pinhao:main

Conversation

@pinhao
Copy link
Copy Markdown

@pinhao pinhao commented Apr 29, 2026

Description

Fixes #24828

Thumbnail generation already selects a specific video stream through VideoStreamInfo.index, but the metadata bitstream filter was -bsf:v, which applies to every video stream in the input.

This can fail for valid video containers that include additional video streams. In one reproducible case, a DJI Osmo Action 6 MP4 contains a primary HEVC stream and an attached MJPEG picture stream. FFmpeg fails because hevc_metadata is applied to the MJPEG stream.
This change the bitstream filter to the main video stream index.

How Has This Been Tested?

  • Reproduced the failure with a DJI Osmo Action 6 MP4 file.
  • Confirmed the original command failed with FFmpeg applying hevc_metadata to the MJPEG stream.
  • Applied the change locally and rebuilt the server.
  • Forced thumbnail generation and confirmed that the job no longer fails with the hevc_metadata FFmpeg error.

Checklist:

  • I have carefully read CONTRIBUTING.md
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Please describe to which degree, if any, an LLM was used in creating this pull request.

No LLM was used

pinhao added 2 commits April 29, 2026 13:37
Prevent ffmpeg errors when generating thumbnails.
Without specifying the index of the video stream the options were applying to all video streams in the file.
In the case of files generated by dji osmo action 6, that caused ffmpeg to throw an error because it has an hevc and mjpeg stream.
Didn't need to remap video
@pinhao pinhao requested a review from danieldietzler as a code owner April 29, 2026 21:55
@immich-push-o-matic
Copy link
Copy Markdown

immich-push-o-matic Bot commented Apr 29, 2026

Label error. Requires exactly 1 of: changelog:.*. Found: 🗄️server. A maintainer will add the required label.

@mertalev
Copy link
Copy Markdown
Member

Thanks for the PR! You'll need to update the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Immich Thumbnail Jellyfin MJPEG bug

2 participants