[PR #3953] [CLOSED] fix(server): set stream with -map flag #10176

Closed
opened 2026-02-05 14:17:13 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/3953
Author: @mertalev
Created: 9/2/2023
Status: Closed

Base: mainHead: fix/server-map-stream


📝 Commits (3)

📊 Changes

4 files changed (+155 additions, -80 deletions)

View changed files

📝 server/src/domain/media/media.service.spec.ts (+140 -70)
📝 server/src/domain/media/media.util.ts (+13 -7)
📝 server/src/infra/repositories/media.repository.ts (+0 -1)
📝 server/test/fixtures/media.stub.ts (+2 -2)

📄 Description

Description

Explicitly sets the video and audio stream to use for transcoding. The previous related PR, #3903, did not actually fix the issue as the stream selection in -c:v:[stream] only applies to that flag and doesn't change the stream FFmpeg ultimately uses for the output video. This PR uses the -map flag instead. It also handles the absence of an audio stream, while the earlier PR would try to read the index from an undefined object.

Fixes #3421

How Has This Been Tested?

Tested on the video provided in #3413 with the below settings, with accel tested with disabled and nvenc. The video transcodes successfully per the logs and plays for its full duration.

"ffmpeg": {
  "targetAudioCodec": "opus",
  "targetResolution": "1080",
  "crf": 25,
  "preset": "slower",
  "twoPass": true,
  "threads": 2,
  "accel": "nvenc",
  "targetVideoCodec": "hevc",
  "transcode": "all",
  "maxBitrate": "0",
  "tonemap": "hable"
}

Edit: Additionally tested by running a transcoding job with no errors after applying a fix for audio streams.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/3953 **Author:** [@mertalev](https://github.com/mertalev) **Created:** 9/2/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/server-map-stream` --- ### 📝 Commits (3) - [`74f53e9`](https://github.com/immich-app/immich/commit/74f53e95193bc2a90bb6cab42c1797f71c99c108) set stream with `-map` flag - [`19fb0fc`](https://github.com/immich-app/immich/commit/19fb0fc345c9b0f1f055b537892ceace55e380b2) updated tests - [`fccca47`](https://github.com/immich-app/immich/commit/fccca4759e342c0e10e8a44acbc4980ea2385a92) fixed audio stream mapping ### 📊 Changes **4 files changed** (+155 additions, -80 deletions) <details> <summary>View changed files</summary> 📝 `server/src/domain/media/media.service.spec.ts` (+140 -70) 📝 `server/src/domain/media/media.util.ts` (+13 -7) 📝 `server/src/infra/repositories/media.repository.ts` (+0 -1) 📝 `server/test/fixtures/media.stub.ts` (+2 -2) </details> ### 📄 Description ## Description Explicitly sets the video and audio stream to use for transcoding. The previous related PR, #3903, did not actually fix the issue as the stream selection in `-c:v:[stream]` only applies to that flag and doesn't change the stream FFmpeg ultimately uses for the output video. This PR uses the `-map` flag instead. It also handles the absence of an audio stream, while the earlier PR would try to read the index from an undefined object. Fixes #3421 ## How Has This Been Tested? Tested on the video provided in #3413 with the below settings, with `accel` tested with `disabled` and `nvenc`. The video transcodes successfully per the logs and plays for its full duration. ``` "ffmpeg": { "targetAudioCodec": "opus", "targetResolution": "1080", "crf": 25, "preset": "slower", "twoPass": true, "threads": 2, "accel": "nvenc", "targetVideoCodec": "hevc", "transcode": "all", "maxBitrate": "0", "tonemap": "hable" } ``` Edit: Additionally tested by running a transcoding job with no errors after applying a fix for audio streams. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:17:13 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#10176