mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
update container value
This commit is contained in:
parent
e208ef19b0
commit
d8e2887071
13 changed files with 116 additions and 48 deletions
|
@ -779,7 +779,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
if (string.IsNullOrEmpty(container))
|
if (string.IsNullOrEmpty(container))
|
||||||
{
|
{
|
||||||
container = request.Static ?
|
container = request.Static ?
|
||||||
state.InputContainer :
|
StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(state.InputContainer, null, DlnaProfileType.Audio) :
|
||||||
GetOutputFileExtension(state);
|
GetOutputFileExtension(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
var authInfo = _authContext.GetAuthorizationInfo(Request);
|
var authInfo = _authContext.GetAuthorizationInfo(Request);
|
||||||
|
|
||||||
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
|
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
var profile = request.DeviceProfile;
|
var profile = request.DeviceProfile;
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
@ -144,6 +144,11 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result.MediaSource != null)
|
||||||
|
{
|
||||||
|
NormalizeMediaSourceContainer(result.MediaSource, profile, DlnaProfileType.Video);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,9 +212,22 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.MediaSources != null)
|
||||||
|
{
|
||||||
|
foreach (var mediaSource in info.MediaSources)
|
||||||
|
{
|
||||||
|
NormalizeMediaSourceContainer(mediaSource, profile, DlnaProfileType.Video);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NormalizeMediaSourceContainer(MediaSourceInfo mediaSource, DeviceProfile profile, DlnaProfileType type)
|
||||||
|
{
|
||||||
|
mediaSource.Container = StreamBuilder.NormalizeMediaSourceFormatIntoSingleContainer(mediaSource.Container, profile, type);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<object> Post(GetPostedPlaybackInfo request)
|
public async Task<object> Post(GetPostedPlaybackInfo request)
|
||||||
{
|
{
|
||||||
var result = await GetPlaybackInfo(request).ConfigureAwait(false);
|
var result = await GetPlaybackInfo(request).ConfigureAwait(false);
|
||||||
|
|
|
@ -167,7 +167,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
// Static stream
|
// Static stream
|
||||||
if (request.Static)
|
if (request.Static)
|
||||||
{
|
{
|
||||||
var contentType = state.GetMimeType(state.MediaPath);
|
var contentType = state.GetMimeType("." + state.OutputContainer, false) ?? state.GetMimeType(state.MediaPath);
|
||||||
|
|
||||||
using (state)
|
using (state)
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,14 +131,14 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
public long? EncodingDurationTicks { get; set; }
|
public long? EncodingDurationTicks { get; set; }
|
||||||
|
|
||||||
public string GetMimeType(string outputPath)
|
public string GetMimeType(string outputPath, bool enableStreamDefault = true)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(MimeType))
|
if (!string.IsNullOrEmpty(MimeType))
|
||||||
{
|
{
|
||||||
return MimeType;
|
return MimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MimeTypes.GetMimeType(outputPath);
|
return MimeTypes.GetMimeType(outputPath, enableStreamDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnableDlnaHeaders { get; set; }
|
public bool EnableDlnaHeaders { get; set; }
|
||||||
|
|
|
@ -10,6 +10,7 @@ using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.MediaEncoding
|
namespace MediaBrowser.Controller.MediaEncoding
|
||||||
{
|
{
|
||||||
|
@ -148,10 +149,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
|
||||||
public string GetInputFormat(string container)
|
public string GetInputFormat(string container)
|
||||||
{
|
{
|
||||||
if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase))
|
if (string.IsNullOrWhiteSpace(container))
|
||||||
{
|
{
|
||||||
return "matroska";
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container = container.Replace("mkv", "matroska", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return "mpegts";
|
return "mpegts";
|
||||||
|
@ -1694,7 +1698,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
state.InputAudioSync = "1";
|
state.InputAudioSync = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Seeing some stuttering when transcoding wma to audio-only HLS
|
// Seeing some stuttering when transcoding wma to audio-only HLS
|
||||||
state.InputAudioSync = "1";
|
state.InputAudioSync = "1";
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
|
|
||||||
if (data.format != null)
|
if (data.format != null)
|
||||||
{
|
{
|
||||||
info.Container = data.format.format_name;
|
info.Container = NormalizeFormat(data.format.format_name);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
if (!string.IsNullOrEmpty(data.format.bit_rate))
|
||||||
{
|
{
|
||||||
|
@ -195,6 +195,23 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string NormalizeFormat(string format)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(format))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(format, "mpegvideo", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return "mpeg";
|
||||||
|
}
|
||||||
|
|
||||||
|
format = format.Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
private int? GetEstimatedAudioBitrate(string codec, int? channels)
|
private int? GetEstimatedAudioBitrate(string codec, int? channels)
|
||||||
{
|
{
|
||||||
if (!channels.HasValue)
|
if (!channels.HasValue)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
|
|
|
@ -187,17 +187,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
|
|
||||||
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate, int? audioSampleRate, int? audioBitDepth)
|
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate, int? audioSampleRate, int? audioBitDepth)
|
||||||
{
|
{
|
||||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
|
||||||
|
|
||||||
foreach (var i in ResponseProfiles)
|
foreach (var i in ResponseProfiles)
|
||||||
{
|
{
|
||||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Audio)
|
if (i.Type != DlnaProfileType.Audio)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> containers = i.GetContainers();
|
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +205,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
var conditionProcessor = new ConditionProcessor();
|
||||||
|
|
||||||
var anyOff = false;
|
var anyOff = false;
|
||||||
foreach (ProfileCondition c in i.Conditions)
|
foreach (ProfileCondition c in i.Conditions)
|
||||||
|
@ -230,9 +227,9 @@ namespace MediaBrowser.Model.Dlna
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaBrowser.Model.Dlna.ProfileCondition GetModelProfileCondition(ProfileCondition c)
|
private ProfileCondition GetModelProfileCondition(ProfileCondition c)
|
||||||
{
|
{
|
||||||
return new MediaBrowser.Model.Dlna.ProfileCondition
|
return new ProfileCondition
|
||||||
{
|
{
|
||||||
Condition = c.Condition,
|
Condition = c.Condition,
|
||||||
IsRequired = c.IsRequired,
|
IsRequired = c.IsRequired,
|
||||||
|
@ -243,22 +240,19 @@ namespace MediaBrowser.Model.Dlna
|
||||||
|
|
||||||
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
|
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
|
||||||
{
|
{
|
||||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
|
||||||
|
|
||||||
foreach (var i in ResponseProfiles)
|
foreach (var i in ResponseProfiles)
|
||||||
{
|
{
|
||||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Photo)
|
if (i.Type != DlnaProfileType.Photo)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> containers = i.GetContainers();
|
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
var conditionProcessor = new ConditionProcessor();
|
||||||
|
|
||||||
var anyOff = false;
|
var anyOff = false;
|
||||||
foreach (ProfileCondition c in i.Conditions)
|
foreach (ProfileCondition c in i.Conditions)
|
||||||
|
@ -300,17 +294,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
string videoCodecTag,
|
string videoCodecTag,
|
||||||
bool? isAvc)
|
bool? isAvc)
|
||||||
{
|
{
|
||||||
container = StringHelper.TrimStart(container ?? string.Empty, '.');
|
|
||||||
|
|
||||||
foreach (var i in ResponseProfiles)
|
foreach (var i in ResponseProfiles)
|
||||||
{
|
{
|
||||||
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Video)
|
if (i.Type != DlnaProfileType.Video)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<string> containers = i.GetContainers();
|
if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
|
||||||
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -327,7 +318,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var conditionProcessor = new MediaBrowser.Model.Dlna.ConditionProcessor();
|
var conditionProcessor = new ConditionProcessor();
|
||||||
|
|
||||||
var anyOff = false;
|
var anyOff = false;
|
||||||
foreach (ProfileCondition c in i.Conditions)
|
foreach (ProfileCondition c in i.Conditions)
|
||||||
|
|
|
@ -33,12 +33,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
|
|
||||||
public List<string> GetContainers()
|
public List<string> GetContainers()
|
||||||
{
|
{
|
||||||
List<string> list = new List<string>();
|
return ContainerProfile.SplitValue(Container);
|
||||||
foreach (string i in (Container ?? string.Empty).Split(','))
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetAudioCodecs()
|
public List<string> GetAudioCodecs()
|
||||||
|
|
|
@ -197,6 +197,40 @@ namespace MediaBrowser.Model.Dlna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string NormalizeMediaSourceFormatIntoSingleContainer(string inputContainer, DeviceProfile profile, DlnaProfileType type)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(inputContainer))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var formats = ContainerProfile.SplitValue(inputContainer);
|
||||||
|
|
||||||
|
if (formats.Count == 1)
|
||||||
|
{
|
||||||
|
return formats[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile != null)
|
||||||
|
{
|
||||||
|
foreach (var format in formats)
|
||||||
|
{
|
||||||
|
foreach (var directPlayProfile in profile.DirectPlayProfiles)
|
||||||
|
{
|
||||||
|
if (directPlayProfile.Type == type)
|
||||||
|
{
|
||||||
|
if (directPlayProfile.SupportsContainer(format))
|
||||||
|
{
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return formats[0];
|
||||||
|
}
|
||||||
|
|
||||||
private StreamInfo BuildAudioItem(MediaSourceInfo item, AudioOptions options)
|
private StreamInfo BuildAudioItem(MediaSourceInfo item, AudioOptions options)
|
||||||
{
|
{
|
||||||
List<TranscodeReason> transcodeReasons = new List<TranscodeReason>();
|
List<TranscodeReason> transcodeReasons = new List<TranscodeReason>();
|
||||||
|
@ -214,14 +248,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (options.ForceDirectPlay)
|
if (options.ForceDirectPlay)
|
||||||
{
|
{
|
||||||
playlistItem.PlayMethod = PlayMethod.DirectPlay;
|
playlistItem.PlayMethod = PlayMethod.DirectPlay;
|
||||||
playlistItem.Container = item.Container;
|
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||||
return playlistItem;
|
return playlistItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.ForceDirectStream)
|
if (options.ForceDirectStream)
|
||||||
{
|
{
|
||||||
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
||||||
playlistItem.Container = item.Container;
|
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||||
return playlistItem;
|
return playlistItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +329,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
playlistItem.PlayMethod = PlayMethod.DirectStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlistItem.Container = item.Container;
|
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Audio);
|
||||||
|
|
||||||
return playlistItem;
|
return playlistItem;
|
||||||
}
|
}
|
||||||
|
@ -648,7 +682,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
if (directPlay != null)
|
if (directPlay != null)
|
||||||
{
|
{
|
||||||
playlistItem.PlayMethod = directPlay.Value;
|
playlistItem.PlayMethod = directPlay.Value;
|
||||||
playlistItem.Container = item.Container;
|
playlistItem.Container = NormalizeMediaSourceFormatIntoSingleContainer(item.Container, options.Profile, DlnaProfileType.Video);
|
||||||
|
|
||||||
if (subtitleStream != null)
|
if (subtitleStream != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,14 +106,15 @@ namespace MediaBrowser.Model.Net
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetMimeType(string path)
|
||||||
|
{
|
||||||
|
return GetMimeType(path, true);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type of the MIME.
|
/// Gets the type of the MIME.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path.</param>
|
public static string GetMimeType(string path, bool enableStreamDefault)
|
||||||
/// <returns>System.String.</returns>
|
|
||||||
/// <exception cref="ArgumentNullException">path</exception>
|
|
||||||
/// <exception cref="InvalidOperationException">Argument not supported: + path</exception>
|
|
||||||
public static string GetMimeType(string path)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
|
@ -329,7 +330,12 @@ namespace MediaBrowser.Model.Net
|
||||||
return "application/ttml+xml";
|
return "application/ttml+xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "application/octet-stream";
|
if (enableStreamDefault)
|
||||||
|
{
|
||||||
|
return "application/octet-stream";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToExtension(string mimeType)
|
public static string ToExtension(string mimeType)
|
||||||
|
|
|
@ -95,14 +95,14 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
{
|
{
|
||||||
var mediaStreams = mediaInfo.MediaStreams;
|
var mediaStreams = mediaInfo.MediaStreams;
|
||||||
|
|
||||||
//audio.FormatName = mediaInfo.Container;
|
audio.Container = mediaInfo.Container;
|
||||||
audio.TotalBitrate = mediaInfo.Bitrate;
|
audio.TotalBitrate = mediaInfo.Bitrate;
|
||||||
|
|
||||||
audio.RunTimeTicks = mediaInfo.RunTimeTicks;
|
audio.RunTimeTicks = mediaInfo.RunTimeTicks;
|
||||||
audio.Size = mediaInfo.Size;
|
audio.Size = mediaInfo.Size;
|
||||||
|
|
||||||
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
|
var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.');
|
||||||
audio.Container = extension;
|
//audio.Container = extension;
|
||||||
|
|
||||||
await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false);
|
await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false);
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
{
|
{
|
||||||
video.Container = null;
|
video.Container = null;
|
||||||
}
|
}
|
||||||
|
video.Container = mediaInfo.Container;
|
||||||
|
|
||||||
var chapters = mediaInfo.Chapters ?? new List<ChapterInfo>();
|
var chapters = mediaInfo.Chapters ?? new List<ChapterInfo>();
|
||||||
if (blurayInfo != null)
|
if (blurayInfo != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue