mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Apply review suggestions
This commit is contained in:
parent
128d54622a
commit
a4e4b761d5
@ -5763,7 +5763,7 @@ AND Type = @InternalPersonType)");
|
|||||||
{
|
{
|
||||||
var itemIdBlob = id.ToByteArray();
|
var itemIdBlob = id.ToByteArray();
|
||||||
|
|
||||||
// First delete chapters
|
// Delete existing mediastreams
|
||||||
db.Execute("delete from mediastreams where ItemId=@ItemId", itemIdBlob);
|
db.Execute("delete from mediastreams where ItemId=@ItemId", itemIdBlob);
|
||||||
|
|
||||||
InsertMediaStreams(itemIdBlob, streams, db);
|
InsertMediaStreams(itemIdBlob, streams, db);
|
||||||
@ -5867,10 +5867,10 @@ AND Type = @InternalPersonType)");
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the chapter.
|
/// Gets the media stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="reader">The reader.</param>
|
/// <param name="reader">The reader.</param>
|
||||||
/// <returns>ChapterInfo.</returns>
|
/// <returns>MediaStream.</returns>
|
||||||
private MediaStream GetMediaStream(IReadOnlyList<ResultSetValue> reader)
|
private MediaStream GetMediaStream(IReadOnlyList<ResultSetValue> reader)
|
||||||
{
|
{
|
||||||
var item = new MediaStream
|
var item = new MediaStream
|
||||||
|
@ -153,9 +153,9 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
// If file is strm or main media stream is missing, force a metadata refresh with remote probing
|
// If file is strm or main media stream is missing, force a metadata refresh with remote probing
|
||||||
if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder
|
if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder
|
||||||
&& (item.Path.EndsWith(".strm")
|
&& (item.Path.EndsWith(".strm", StringComparison.OrdinalIgnoreCase)
|
||||||
|| (item.MediaType == MediaType.Video && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Video))
|
|| (item.MediaType == MediaType.Video && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Video))
|
||||||
|| (item.MediaType == MediaType.Audio && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio))))
|
|| (item.MediaType == MediaType.Audio && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio))))
|
||||||
{
|
{
|
||||||
await item.RefreshMetadata(
|
await item.RefreshMetadata(
|
||||||
new MetadataRefreshOptions(_directoryService)
|
new MetadataRefreshOptions(_directoryService)
|
||||||
|
@ -2215,23 +2215,24 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
return state.IsInputVideo ? "-sn" : string.Empty;
|
return state.IsInputVideo ? "-sn" : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have media info, but we don't know the stream indexes
|
// We have media info, but we don't know the stream index
|
||||||
if (state.VideoStream != null && state.VideoStream.Index == -1)
|
if (state.VideoStream != null && state.VideoStream.Index == -1)
|
||||||
{
|
{
|
||||||
return "-sn";
|
return "-sn";
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have media info, but we don't know the stream indexes
|
// We have media info, but we don't know the stream index
|
||||||
if (state.AudioStream != null && state.AudioStream.Index == -1)
|
if (state.AudioStream != null && state.AudioStream.Index == -1)
|
||||||
{
|
{
|
||||||
return state.IsInputVideo ? "-sn" : string.Empty;
|
return state.IsInputVideo ? "-sn" : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = string.Empty;
|
var args = string.Empty;
|
||||||
int videoStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.VideoStream.Path).ToList().IndexOf(state.VideoStream);
|
|
||||||
|
|
||||||
if (state.VideoStream != null)
|
if (state.VideoStream != null)
|
||||||
{
|
{
|
||||||
|
int videoStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.VideoStream);
|
||||||
|
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"-map 0:{0}",
|
"-map 0:{0}",
|
||||||
@ -2245,26 +2246,24 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
if (state.AudioStream != null)
|
if (state.AudioStream != null)
|
||||||
{
|
{
|
||||||
|
int audioStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.AudioStream);
|
||||||
if (state.AudioStream.IsExternal)
|
if (state.AudioStream.IsExternal)
|
||||||
{
|
{
|
||||||
bool hasExternalGraphicsSubs = state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream;
|
bool hasExternalGraphicsSubs = state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
int externalAudioMapIndex = hasExternalGraphicsSubs ? 2 : 1;
|
int externalAudioMapIndex = hasExternalGraphicsSubs ? 2 : 1;
|
||||||
int externalAudioStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.AudioStream.Path).ToList().IndexOf(state.AudioStream);
|
|
||||||
|
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
" -map {0}:{1}",
|
" -map {0}:{1}",
|
||||||
externalAudioMapIndex,
|
externalAudioMapIndex,
|
||||||
externalAudioStreamIndex);
|
audioStreamIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int subtitleStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.AudioStream.Path).ToList().IndexOf(state.AudioStream);
|
|
||||||
|
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
" -map 0:{0}",
|
" -map 0:{0}",
|
||||||
subtitleStreamIndex);
|
audioStreamIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2279,7 +2278,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
else if (subtitleMethod == SubtitleDeliveryMethod.Embed)
|
else if (subtitleMethod == SubtitleDeliveryMethod.Embed)
|
||||||
{
|
{
|
||||||
int subtitleStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.SubtitleStream.Path).ToList().IndexOf(state.SubtitleStream);
|
int subtitleStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.SubtitleStream);
|
||||||
|
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
@ -2288,7 +2287,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
else if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
|
else if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
|
||||||
{
|
{
|
||||||
int externalSubtitleStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.SubtitleStream.Path).ToList().IndexOf(state.SubtitleStream);
|
int externalSubtitleStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.SubtitleStream);
|
||||||
|
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
@ -4139,8 +4138,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
string.Join(',', overlayFilters));
|
string.Join(',', overlayFilters));
|
||||||
|
|
||||||
var mapPrefix = Convert.ToInt32(state.SubtitleStream.IsExternal);
|
var mapPrefix = Convert.ToInt32(state.SubtitleStream.IsExternal);
|
||||||
var subtitleStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.SubtitleStream.Path).ToList().IndexOf(state.SubtitleStream);
|
var subtitleStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.SubtitleStream);
|
||||||
var videoStreamIndex = state.MediaSource.MediaStreams.Where(i => i.Path == state.VideoStream.Path).ToList().IndexOf(state.VideoStream);
|
var videoStreamIndex = FindIndex(state.MediaSource.MediaStreams, state.VideoStream);
|
||||||
|
|
||||||
if (hasSubs)
|
if (hasSubs)
|
||||||
{
|
{
|
||||||
@ -5398,6 +5397,28 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
string.Empty).Trim();
|
string.Empty).Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int FindIndex(IReadOnlyList<MediaStream> mediaStreams, MediaStream streamToFind)
|
||||||
|
{
|
||||||
|
var index = 0;
|
||||||
|
var length = mediaStreams.Count;
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
var currentMediaStream = mediaStreams[i];
|
||||||
|
if (currentMediaStream == streamToFind)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(currentMediaStream.Path, streamToFind.Path, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsCopyCodec(string codec)
|
public static bool IsCopyCodec(string codec)
|
||||||
{
|
{
|
||||||
return string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
return string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
||||||
|
@ -419,9 +419,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||||||
/// <exception cref="ArgumentException">Unrecognized InputType.</exception>
|
/// <exception cref="ArgumentException">Unrecognized InputType.</exception>
|
||||||
public string GetExternalSubtitleInputArgument(string inputFile)
|
public string GetExternalSubtitleInputArgument(string inputFile)
|
||||||
{
|
{
|
||||||
var prefix = "file";
|
const string Prefix = "file";
|
||||||
|
|
||||||
return EncodingUtils.GetInputArgument(prefix, inputFile, MediaProtocol.File);
|
return EncodingUtils.GetInputArgument(Prefix, inputFile, MediaProtocol.File);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -195,7 +195,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
MediaStream subtitleStream,
|
MediaStream subtitleStream,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (!subtitleStream.IsExternal || subtitleStream.Path.EndsWith(".mks"))
|
if (!subtitleStream.IsExternal || subtitleStream.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
string outputFormat;
|
string outputFormat;
|
||||||
string outputCodec;
|
string outputCodec;
|
||||||
@ -511,7 +511,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|||||||
|
|
||||||
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await semaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var subtitleStreamIndex = mediaSource.MediaStreams.Where(i => i.Path == subtitleStream.Path).ToList().IndexOf(subtitleStream);
|
var subtitleStreamIndex = EncodingHelper.FindIndex(mediaSource.MediaStreams, subtitleStream);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -180,7 +180,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
|
|
||||||
await AddExternalAudioAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
|
await AddExternalAudioAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var startIndex = mediaStreams.Count == 0 ? 0 : (mediaStreams.Select(i => i.Index).Max() + 1);
|
var startIndex = mediaStreams.Count == 0 ? 0 : (mediaStreams.Max(i => i.Index) + 1);
|
||||||
|
|
||||||
if (mediaInfo != null)
|
if (mediaInfo != null)
|
||||||
{
|
{
|
||||||
@ -196,7 +196,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
// video.FormatName = (mediaInfo.Container ?? string.Empty)
|
// video.FormatName = (mediaInfo.Container ?? string.Empty)
|
||||||
// .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase);
|
// .Replace("matroska", "mkv", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// For dvd's this may not always be accurate, so don't set the runtime if the item already has one
|
// For DVDs this may not always be accurate, so don't set the runtime if the item already has one
|
||||||
var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0;
|
var needToSetRuntime = video.VideoType != VideoType.Dvd || video.RunTimeTicks == null || video.RunTimeTicks.Value == 0;
|
||||||
|
|
||||||
if (needToSetRuntime)
|
if (needToSetRuntime)
|
||||||
@ -227,12 +227,16 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var nonExternalMediaStreams = video.GetMediaStreams().Where(i => !i.IsExternal);
|
var currentMediaStreams = video.GetMediaStreams();
|
||||||
foreach (var mediaStream in nonExternalMediaStreams)
|
foreach (var mediaStream in currentMediaStreams)
|
||||||
{
|
{
|
||||||
mediaStream.Index = startIndex++;
|
if (!mediaStream.IsExternal)
|
||||||
mediaStreams.Add(mediaStream);
|
{
|
||||||
|
mediaStream.Index = startIndex++;
|
||||||
|
mediaStreams.Add(mediaStream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaAttachments = Array.Empty<MediaAttachment>();
|
mediaAttachments = Array.Empty<MediaAttachment>();
|
||||||
chapters = Array.Empty<ChapterInfo>();
|
chapters = Array.Empty<ChapterInfo>();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user