aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2022-05-04 08:20:48 -0600
committercrobibero <cody@robibe.ro>2022-05-20 18:30:56 -0400
commitefcdab116f85a560c9362185a9e333c3fc9df41d (patch)
tree237fea205b6861c4649c9aba057e10680f06bbaf /MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
parent5e593cf29c6e508523150e054f8c2f036358c164 (diff)
Merge pull request #7529 from Shadowghost/strm-ffprobe-external-fix
(cherry picked from commit 60affd096595d68728506149d0ffce6e84b6b015) Signed-off-by: crobibero <cody@robibe.ro>
Diffstat (limited to 'MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs')
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs39
1 files changed, 31 insertions, 8 deletions
diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
index 4a289b3ab..8c08ab30e 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs
@@ -173,16 +173,30 @@ namespace MediaBrowser.Providers.MediaInfo
IReadOnlyList<MediaAttachment> mediaAttachments;
ChapterInfo[] chapters;
+ mediaStreams = new List<MediaStream>();
+
+ // Add external streams before adding the streams from the file to preserve stream IDs on remote videos
+ await AddExternalSubtitlesAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
+
+ await AddExternalAudioAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
+
+ var startIndex = mediaStreams.Count == 0 ? 0 : (mediaStreams.Max(i => i.Index) + 1);
+
if (mediaInfo != null)
{
- mediaStreams = mediaInfo.MediaStreams.ToList();
+ foreach (var mediaStream in mediaInfo.MediaStreams)
+ {
+ mediaStream.Index = startIndex++;
+ mediaStreams.Add(mediaStream);
+ }
+
mediaAttachments = mediaInfo.MediaAttachments;
video.TotalBitrate = mediaInfo.Bitrate;
// video.FormatName = (mediaInfo.Container ?? string.Empty)
// .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;
if (needToSetRuntime)
@@ -213,15 +227,20 @@ namespace MediaBrowser.Providers.MediaInfo
}
else
{
- mediaStreams = new List<MediaStream>();
+ var currentMediaStreams = video.GetMediaStreams();
+ foreach (var mediaStream in currentMediaStreams)
+ {
+ if (!mediaStream.IsExternal)
+ {
+ mediaStream.Index = startIndex++;
+ mediaStreams.Add(mediaStream);
+ }
+ }
+
mediaAttachments = Array.Empty<MediaAttachment>();
chapters = Array.Empty<ChapterInfo>();
}
- await AddExternalSubtitlesAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
-
- await AddExternalAudioAsync(video, mediaStreams, options, cancellationToken).ConfigureAwait(false);
-
var libraryOptions = _libraryManager.GetLibraryOptions(video);
if (mediaInfo != null)
@@ -254,7 +273,11 @@ namespace MediaBrowser.Providers.MediaInfo
video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle);
_itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken);
- _itemRepo.SaveMediaAttachments(video.Id, mediaAttachments, cancellationToken);
+
+ if (mediaAttachments.Any())
+ {
+ _itemRepo.SaveMediaAttachments(video.Id, mediaAttachments, cancellationToken);
+ }
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
options.MetadataRefreshMode == MetadataRefreshMode.Default)