diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index c96ca87a56..b552df0a45 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -179,7 +179,7 @@ namespace Jellyfin.Api.Helpers
{
containerInternal = streamingRequest.Static ?
StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(state.InputContainer, null, DlnaProfileType.Audio)
- : GetOutputFileExtension(state);
+ : GetOutputFileExtension(state, mediaSource);
}
state.OutputContainer = (containerInternal ?? string.Empty).TrimStart('.');
@@ -235,7 +235,7 @@ namespace Jellyfin.Api.Helpers
ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, streamingRequest.DeviceProfileId, streamingRequest.Static);
var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
- ? GetOutputFileExtension(state)
+ ? GetOutputFileExtension(state, mediaSource)
: ("." + state.OutputContainer);
state.OutputFilePath = GetOutputFilePath(state, ext!, serverConfigurationManager, streamingRequest.DeviceId, streamingRequest.PlaySessionId);
@@ -409,8 +409,9 @@ namespace Jellyfin.Api.Helpers
/// Gets the output file extension.
///
/// The state.
+ /// The mediaSource.
/// System.String.
- private static string? GetOutputFileExtension(StreamState state)
+ private static string? GetOutputFileExtension(StreamState state, MediaSourceInfo? mediaSource)
{
var ext = Path.GetExtension(state.RequestedUrl);
@@ -425,7 +426,7 @@ namespace Jellyfin.Api.Helpers
var videoCodec = state.Request.VideoCodec;
if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(videoCodec, "h265", StringComparison.OrdinalIgnoreCase))
+ string.Equals(videoCodec, "hevc", StringComparison.OrdinalIgnoreCase))
{
return ".ts";
}
@@ -474,6 +475,13 @@ namespace Jellyfin.Api.Helpers
}
}
+ // Fallback to the container of mediaSource
+ if (!string.IsNullOrEmpty(mediaSource?.Container))
+ {
+ var idx = mediaSource.Container.IndexOf(',', StringComparison.OrdinalIgnoreCase);
+ return '.' + (idx == -1 ? mediaSource.Container : mediaSource.Container[..idx]).Trim();
+ }
+
return null;
}