mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Properly handle stream addition and removal for strm use cases
This commit is contained in:
parent
3229ba4918
commit
21ce0e58c6
@ -151,7 +151,9 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
var mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user);
|
var mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user);
|
||||||
|
|
||||||
if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio || i.Type == MediaStreamType.Video))
|
if (allowMediaProbe && mediaSources[0].Type != MediaSourceType.Placeholder
|
||||||
|
&& (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)))
|
||||||
{
|
{
|
||||||
await item.RefreshMetadata(
|
await item.RefreshMetadata(
|
||||||
new MetadataRefreshOptions(_directoryService)
|
new MetadataRefreshOptions(_directoryService)
|
||||||
|
@ -2228,13 +2228,14 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
|
|
||||||
var args = string.Empty;
|
var args = string.Empty;
|
||||||
|
var numberOfExternalStreams = state.MediaSource.MediaStreams.Where(stream => stream.IsExternal == true).Count();
|
||||||
|
|
||||||
if (state.VideoStream != null)
|
if (state.VideoStream != null)
|
||||||
{
|
{
|
||||||
args += string.Format(
|
args += string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"-map 0:{0}",
|
"-map 0:{0}",
|
||||||
state.VideoStream.Index);
|
state.VideoStream.Index - numberOfExternalStreams);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -173,9 +173,22 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
IReadOnlyList<MediaAttachment> mediaAttachments;
|
IReadOnlyList<MediaAttachment> mediaAttachments;
|
||||||
ChapterInfo[] chapters;
|
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);
|
||||||
|
|
||||||
if (mediaInfo != null)
|
if (mediaInfo != null)
|
||||||
{
|
{
|
||||||
mediaStreams = mediaInfo.MediaStreams.ToList();
|
var startIndex = mediaStreams.Count == 0 ? 0 : (mediaStreams.Select(i => i.Index).Max() + 1);
|
||||||
|
foreach (var mediaStream in mediaInfo.MediaStreams)
|
||||||
|
{
|
||||||
|
mediaStream.Index = startIndex++;
|
||||||
|
mediaStreams.Add(mediaStream);
|
||||||
|
}
|
||||||
|
|
||||||
mediaAttachments = mediaInfo.MediaAttachments;
|
mediaAttachments = mediaInfo.MediaAttachments;
|
||||||
|
|
||||||
video.TotalBitrate = mediaInfo.Bitrate;
|
video.TotalBitrate = mediaInfo.Bitrate;
|
||||||
@ -213,15 +226,10 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mediaStreams = new List<MediaStream>();
|
|
||||||
mediaAttachments = Array.Empty<MediaAttachment>();
|
mediaAttachments = Array.Empty<MediaAttachment>();
|
||||||
chapters = Array.Empty<ChapterInfo>();
|
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);
|
var libraryOptions = _libraryManager.GetLibraryOptions(video);
|
||||||
|
|
||||||
if (mediaInfo != null)
|
if (mediaInfo != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user