[PR #15690] [MERGED] Fix: Add .ts fallback for video streams to prevent crash #14388

Closed
opened 2026-02-07 07:29:05 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/15690
Author: @martenumberto
Created: 12/1/2025
Status: Merged
Merged: 12/4/2025
Merged by: @crobibero

Base: release-10.11.zHead: fix-streams-without-fileextensions


📝 Commits (4)

  • f442f70 Fix: Add .ts fallback for video streams to prevent crash
  • 42c1295 Change Logik for LiveStreams without File Extension
  • b6507c8 Removed Comments
  • 8fa6aa9 Also check mediaSource.IsInfiniteStream for LiveTV fallback since LiveStreamId can be null in some cases

📊 Changes

2 files changed (+8 additions, -0 deletions)

View changed files

📝 CONTRIBUTORS.md (+1 -0)
📝 Jellyfin.Api/Helpers/StreamingHelpers.cs (+7 -0)

📄 Description

Describe the changes

This PR adds a defensive fallback to Jellyfin.Api.Helpers.StreamingHelpers.GetOutputFileExtension.

When handling a video request where:

  1. The URL does not contain a file extension (common in IPTV/M3U streams with tokens),
  2. The video codec is not in the hardcoded list (e.g. mpeg2video),
  3. And the MediaSource.Container is not yet populated (due to race conditions during initial probing),

...the server currently throws an InvalidOperationException, resulting in an HTTP 500 error and playback failure.

This change adds a default fallback to .ts (Transport Stream) for video requests when no other extension can be determined. This allows the stream to be passed to ffmpeg for remuxing/transcoding instead of crashing the request.

Fixes

Fixes https://github.com/jellyfin/jellyfin/issues/15643
Duplicate of https://github.com/jellyfin/jellyfin/pull/15644 cause of rebase trouble.

How to test

  1. Add an M3U Tuner with streams that do not have a file extension in the URL (e.g., http://provider/stream/12345?token=abc).
  2. Ensure the stream uses a codec not explicitly handled in StreamingHelpers (e.g., mpeg2video) or trigger a cold start where probing data is missing.
  3. Attempt to play the stream.
  4. Before this fix: Server logs show System.InvalidOperationException: Failed to find an appropriate file extension and playback fails.
  5. After this fix: Playback starts successfully (typically remuxing to TS).

Checklist

  • I have read the contributing guidelines.
  • I have verified that the change works locally.
  • The code follows the project's coding standards.

🔄 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/jellyfin/jellyfin/pull/15690 **Author:** [@martenumberto](https://github.com/martenumberto) **Created:** 12/1/2025 **Status:** ✅ Merged **Merged:** 12/4/2025 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `release-10.11.z` ← **Head:** `fix-streams-without-fileextensions` --- ### 📝 Commits (4) - [`f442f70`](https://github.com/jellyfin/jellyfin/commit/f442f704fecf3910339b035d985beef31400e9a2) Fix: Add .ts fallback for video streams to prevent crash - [`42c1295`](https://github.com/jellyfin/jellyfin/commit/42c1295fd58d7824393bd48ff69b9fb9ffb6f8ac) Change Logik for LiveStreams without File Extension - [`b6507c8`](https://github.com/jellyfin/jellyfin/commit/b6507c89a92418d4e89a7d000ecfdbe7c8583374) Removed Comments - [`8fa6aa9`](https://github.com/jellyfin/jellyfin/commit/8fa6aa946a957ddec9812531384947253cf1f5ee) Also check mediaSource.IsInfiniteStream for LiveTV fallback since LiveStreamId can be null in some cases ### 📊 Changes **2 files changed** (+8 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `CONTRIBUTORS.md` (+1 -0) 📝 `Jellyfin.Api/Helpers/StreamingHelpers.cs` (+7 -0) </details> ### 📄 Description ### Describe the changes This PR adds a defensive fallback to `Jellyfin.Api.Helpers.StreamingHelpers.GetOutputFileExtension`. When handling a video request where: 1. The URL does not contain a file extension (common in IPTV/M3U streams with tokens), 2. The video codec is not in the hardcoded list (e.g. `mpeg2video`), 3. And the `MediaSource.Container` is not yet populated (due to race conditions during initial probing), ...the server currently throws an `InvalidOperationException`, resulting in an HTTP 500 error and playback failure. This change adds a default fallback to `.ts` (Transport Stream) for video requests when no other extension can be determined. This allows the stream to be passed to ffmpeg for remuxing/transcoding instead of crashing the request. ### Fixes Fixes https://github.com/jellyfin/jellyfin/issues/15643 Duplicate of https://github.com/jellyfin/jellyfin/pull/15644 cause of rebase trouble. ### How to test 1. Add an M3U Tuner with streams that do not have a file extension in the URL (e.g., `http://provider/stream/12345?token=abc`). 2. Ensure the stream uses a codec not explicitly handled in `StreamingHelpers` (e.g., `mpeg2video`) or trigger a cold start where probing data is missing. 3. Attempt to play the stream. 4. **Before this fix:** Server logs show `System.InvalidOperationException: Failed to find an appropriate file extension` and playback fails. 5. **After this fix:** Playback starts successfully (typically remuxing to TS). ### Checklist - [x] I have read the contributing guidelines. - [x] I have verified that the change works locally. - [x] The code follows the project's coding standards. --- <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-07 07:29:05 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#14388