mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 05:57:20 -04:00
Fix file extension based on container
This commit is contained in:
parent
7baa261b22
commit
9230472056
3 changed files with 23 additions and 5 deletions
|
@ -458,8 +458,6 @@ public class VideosController : BaseJellyfinApiController
|
|||
return BadRequest($"Input protocol {state.InputProtocol} cannot be streamed statically");
|
||||
}
|
||||
|
||||
var outputPath = state.OutputFilePath;
|
||||
|
||||
// Static stream
|
||||
if (@static.HasValue && @static.Value && !(state.MediaSource.VideoType == VideoType.BluRay || state.MediaSource.VideoType == VideoType.Dvd))
|
||||
{
|
||||
|
@ -478,7 +476,7 @@ public class VideosController : BaseJellyfinApiController
|
|||
|
||||
// Need to start ffmpeg (because media can't be returned directly)
|
||||
var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
|
||||
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, "superfast");
|
||||
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, "superfast");
|
||||
return await FileStreamResponseHelpers.GetTranscodedFile(
|
||||
state,
|
||||
isHeadRequest,
|
||||
|
|
|
@ -225,7 +225,7 @@ public static class StreamingHelpers
|
|||
|
||||
var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
|
||||
? GetOutputFileExtension(state, mediaSource)
|
||||
: ("." + state.OutputContainer);
|
||||
: ("." + GetContainerFileExtension(state.OutputContainer));
|
||||
|
||||
state.OutputFilePath = GetOutputFilePath(state, ext, serverConfigurationManager, streamingRequest.DeviceId, streamingRequest.PlaySessionId);
|
||||
|
||||
|
@ -559,4 +559,23 @@ public static class StreamingHelpers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the container into its file extension.
|
||||
/// </summary>
|
||||
/// <param name="container">The container.</param>
|
||||
private static string? GetContainerFileExtension(string? container)
|
||||
{
|
||||
if (string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "ts";
|
||||
}
|
||||
|
||||
if (string.Equals(container, "matroska", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "mkv";
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6541,13 +6541,14 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
return " -codec:s:0 " + codec + " -disposition:s:0 default";
|
||||
}
|
||||
|
||||
public string GetProgressiveVideoFullCommandLine(EncodingJobInfo state, EncodingOptions encodingOptions, string outputPath, string defaultPreset)
|
||||
public string GetProgressiveVideoFullCommandLine(EncodingJobInfo state, EncodingOptions encodingOptions, string defaultPreset)
|
||||
{
|
||||
// Get the output codec name
|
||||
var videoCodec = GetVideoEncoder(state, encodingOptions);
|
||||
|
||||
var format = string.Empty;
|
||||
var keyFrame = string.Empty;
|
||||
var outputPath = state.OutputFilePath;
|
||||
|
||||
if (Path.GetExtension(outputPath.AsSpan()).Equals(".mp4", StringComparison.OrdinalIgnoreCase)
|
||||
&& state.BaseRequest.Context == EncodingContext.Streaming)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue