From 853dbfc558e271d2287ff30c774884072ee1aa6e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Dec 2016 02:14:59 -0500 Subject: [PATCH 1/5] separate player selection into it's own script --- .../IO/FileRefresher.cs | 7 ++--- .../Library/LibraryManager.cs | 24 ----------------- .../Chapters/IChapterManager.cs | 6 ----- .../Entities/CollectionFolder.cs | 1 - .../Configuration/ChapterOptions.cs | 11 -------- .../Configuration/LibraryOptions.cs | 1 - .../Configuration/ServerConfiguration.cs | 14 ---------- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 - .../Chapters/ChapterManager.cs | 20 -------------- .../Manager/ProviderManager.cs | 26 +++++++------------ .../MediaInfo/FFProbeVideoInfo.cs | 2 +- .../MediaBrowser.WebDashboard.csproj | 3 +++ 12 files changed, 18 insertions(+), 98 deletions(-) delete mode 100644 MediaBrowser.Model/Configuration/ChapterOptions.cs diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs index 39033249f..d7f2ffa43 100644 --- a/Emby.Server.Implementations/IO/FileRefresher.cs +++ b/Emby.Server.Implementations/IO/FileRefresher.cs @@ -261,10 +261,11 @@ namespace Emby.Server.Implementations.IO // In order to determine if the file is being written to, we have to request write access // But if the server only has readonly access, this is going to cause this entire algorithm to fail // So we'll take a best guess about our access level - var requestedFileAccess = ConfigurationManager.Configuration.SaveLocalMeta - ? FileAccessMode.ReadWrite - : FileAccessMode.Read; + //var requestedFileAccess = ConfigurationManager.Configuration.SaveLocalMeta + // ? FileAccessMode.ReadWrite + // : FileAccessMode.Read; + var requestedFileAccess = FileAccessMode.Read; try { using (_fileSystem.GetFileStream(path, FileOpenMode.Open, requestedFileAccess, FileShareMode.ReadWrite)) diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 4c788a2ab..4dd6cd303 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1956,30 +1956,6 @@ namespace Emby.Server.Implementations.Library var options = collectionFolder == null ? new LibraryOptions() : collectionFolder.GetLibraryOptions(); - if (options.SchemaVersion < 3) - { - options.SaveLocalMetadata = ConfigurationManager.Configuration.SaveLocalMeta; - options.EnableInternetProviders = ConfigurationManager.Configuration.EnableInternetProviders; - } - - if (options.SchemaVersion < 2) - { - var chapterOptions = ConfigurationManager.GetConfiguration("chapters"); - options.ExtractChapterImagesDuringLibraryScan = chapterOptions.ExtractDuringLibraryScan; - - if (collectionFolder != null) - { - if (string.Equals(collectionFolder.CollectionType, "movies", StringComparison.OrdinalIgnoreCase)) - { - options.EnableChapterImageExtraction = chapterOptions.EnableMovieChapterImageExtraction; - } - else if (string.Equals(collectionFolder.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) - { - options.EnableChapterImageExtraction = chapterOptions.EnableEpisodeChapterImageExtraction; - } - } - } - return options; } diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 4b39e66cc..05517ebcd 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -26,11 +26,5 @@ namespace MediaBrowser.Controller.Chapters /// The cancellation token. /// Task. Task SaveChapters(string itemId, List chapters, CancellationToken cancellationToken); - - /// - /// Gets the configuration. - /// - /// ChapterOptions. - ChapterOptions GetConfiguration(); } } diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 681f16f07..62ea21a79 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -121,7 +121,6 @@ namespace MediaBrowser.Controller.Entities { LibraryOptions[path] = options; - options.SchemaVersion = 3; XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path)); } } diff --git a/MediaBrowser.Model/Configuration/ChapterOptions.cs b/MediaBrowser.Model/Configuration/ChapterOptions.cs deleted file mode 100644 index 1c2b0c527..000000000 --- a/MediaBrowser.Model/Configuration/ChapterOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace MediaBrowser.Model.Configuration -{ - public class ChapterOptions - { - public bool EnableMovieChapterImageExtraction { get; set; } - public bool EnableEpisodeChapterImageExtraction { get; set; } - public bool EnableOtherVideoChapterImageExtraction { get; set; } - - public bool ExtractDuringLibraryScan { get; set; } - } -} \ No newline at end of file diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs index e79253d19..8e344f76e 100644 --- a/MediaBrowser.Model/Configuration/LibraryOptions.cs +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -5,7 +5,6 @@ public bool EnableArchiveMediaFiles { get; set; } public bool EnablePhotos { get; set; } public bool EnableRealtimeMonitor { get; set; } - public int SchemaVersion { get; set; } public bool EnableChapterImageExtraction { get; set; } public bool ExtractChapterImagesDuringLibraryScan { get; set; } public bool DownloadImagesInAdvance { get; set; } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 22713b94f..bd0a53cc0 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -54,12 +54,6 @@ namespace MediaBrowser.Model.Configuration /// The value pointing to the file system where the ssl certiifcate is located.. public string CertificatePath { get; set; } - /// - /// Gets or sets a value indicating whether [enable internet providers]. - /// - /// true if [enable internet providers]; otherwise, false. - public bool EnableInternetProviders { get; set; } - /// /// Gets or sets a value indicating whether this instance is port authorized. /// @@ -87,12 +81,6 @@ namespace MediaBrowser.Model.Configuration /// The display name of the season zero. public string SeasonZeroDisplayName { get; set; } - /// - /// Gets or sets a value indicating whether [save local meta]. - /// - /// true if [save local meta]; otherwise, false. - public bool SaveLocalMeta { get; set; } - /// /// Gets or sets the preferred metadata language. /// @@ -243,8 +231,6 @@ namespace MediaBrowser.Model.Configuration LibraryMonitorDelay = 60; - EnableInternetProviders = true; - PathSubstitutions = new PathSubstitution[] { }; ContentTypes = new NameValuePair[] { }; diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index f36519e27..4457c6dc2 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -78,7 +78,6 @@ - diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index 87aaafb39..5fea2c3cd 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -43,25 +43,5 @@ namespace MediaBrowser.Providers.Chapters { return _itemRepo.SaveChapters(new Guid(itemId), chapters, cancellationToken); } - - public ChapterOptions GetConfiguration() - { - return _config.GetConfiguration("chapters"); - } - } - - public class ChapterConfigurationStore : IConfigurationFactory - { - public IEnumerable GetConfigurations() - { - return new List - { - new ConfigurationStore - { - Key = "chapters", - ConfigurationType = typeof (ChapterOptions) - } - }; - } } } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index a2f3d0459..a645ab55f 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -510,25 +510,19 @@ namespace MediaBrowser.Providers.Manager Type = MetadataPluginType.LocalMetadataProvider })); - if (item.IsInternetMetadataEnabled()) + // Fetchers + list.AddRange(providers.Where(i => (i is IRemoteMetadataProvider)).Select(i => new MetadataPlugin { - // Fetchers - list.AddRange(providers.Where(i => (i is IRemoteMetadataProvider)).Select(i => new MetadataPlugin - { - Name = i.Name, - Type = MetadataPluginType.MetadataFetcher - })); - } + Name = i.Name, + Type = MetadataPluginType.MetadataFetcher + })); - if (item.IsSaveLocalMetadataEnabled()) + // Savers + list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit, true)).OrderBy(i => i.Name).Select(i => new MetadataPlugin { - // Savers - list.AddRange(_savers.Where(i => IsSaverEnabledForItem(i, item, ItemUpdateType.MetadataEdit, true)).OrderBy(i => i.Name).Select(i => new MetadataPlugin - { - Name = i.Name, - Type = MetadataPluginType.MetadataSaver - })); - } + Name = i.Name, + Type = MetadataPluginType.MetadataSaver + })); } private void AddImagePlugins(List list, T item, List imageProviders) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index c1bae4b3c..c4ea13063 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -417,7 +417,7 @@ namespace MediaBrowser.Providers.MediaInfo } if (!string.IsNullOrWhiteSpace(data.Name)) { - if (string.IsNullOrWhiteSpace(video.Name) || string.Equals(video.Name, Path.GetFileNameWithoutExtension(video.Path), StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrWhiteSpace(video.Name) || (string.Equals(video.Name, Path.GetFileNameWithoutExtension(video.Path), StringComparison.OrdinalIgnoreCase) && !video.ProviderIds.Any())) { // Don't use the embedded name for extras because it will often be the same name as the movie if (!video.ExtraType.HasValue && !video.IsOwnedItem) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 0a67cbdb0..37ee31df1 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -156,6 +156,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 72887a1f6b6abc63f4a412d109241dc5b2ab6a54 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Dec 2016 14:26:45 -0500 Subject: [PATCH 2/5] specify input codecs --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 7f568183e..a768d0cc4 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -2691,6 +2691,18 @@ namespace MediaBrowser.Api.Playback { //inputModifier += " -noaccurate_seek"; } + + var videoStream = state.VideoStream; + if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec)) + { + inputModifier += " -codec:0 " + videoStream.Codec; + + var audioStream = state.AudioStream; + if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec)) + { + inputModifier += " -codec:1 " + audioStream.Codec; + } + } } return inputModifier; From 845895eae4ca8cc0ef64c00397a2c6c3c00c792e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Dec 2016 14:27:14 -0500 Subject: [PATCH 3/5] don't use tmp file --- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 84f395518..17a0eeb8e 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -223,6 +223,7 @@ namespace MediaBrowser.Api.Playback.Hls protected Stream GetPlaylistFileStream(string path) { var tmpPath = path + ".tmp"; + tmpPath = path; try { From 9da48106c893bf179a00db7dadbb74f513277263 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Dec 2016 16:50:53 -0500 Subject: [PATCH 4/5] update logging --- .../Encoder/MediaEncoder.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 89730a11f..c26664921 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -533,8 +533,10 @@ namespace MediaBrowser.MediaEncoding.Encoder probeSize = probeSize + " " + analyzeDuration; probeSize = probeSize.Trim(); + var forceEnableLogging = request.Protocol != MediaProtocol.File; + return GetMediaInfoInternal(GetInputArgument(inputFiles, request.Protocol), request.InputPath, request.Protocol, extractChapters, - probeSize, request.MediaType == DlnaProfileType.Audio, request.VideoType, cancellationToken); + probeSize, request.MediaType == DlnaProfileType.Audio, request.VideoType, forceEnableLogging, cancellationToken); } /// @@ -577,14 +579,6 @@ namespace MediaBrowser.MediaEncoding.Encoder /// /// Gets the media info internal. /// - /// The input path. - /// The primary path. - /// The protocol. - /// if set to true [extract chapters]. - /// The probe size argument. - /// if set to true [is audio]. - /// Type of the video. - /// The cancellation token. /// Task{MediaInfoResult}. private async Task GetMediaInfoInternal(string inputPath, string primaryPath, @@ -593,6 +587,7 @@ namespace MediaBrowser.MediaEncoding.Encoder string probeSizeArgument, bool isAudio, VideoType videoType, + bool forceEnableLogging, CancellationToken cancellationToken) { var args = extractChapters @@ -614,7 +609,14 @@ namespace MediaBrowser.MediaEncoding.Encoder EnableRaisingEvents = true }); - _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + if (forceEnableLogging) + { + _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + } + else + { + _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + } using (var processWrapper = new ProcessWrapper(process, this, _logger)) { From b8f57f586b218558bcb45259d65dfe990e593559 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 30 Dec 2016 00:55:46 -0500 Subject: [PATCH 5/5] update stream specifiers --- .../Playback/BaseStreamingService.cs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index a768d0cc4..dc137521c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1975,7 +1975,7 @@ namespace MediaBrowser.Api.Playback if (state.OutputVideoBitrate.HasValue && !string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase)) { var resolution = ResolutionNormalizer.Normalize( - state.VideoStream == null ? (int?) null : state.VideoStream.BitRate, + state.VideoStream == null ? (int?)null : state.VideoStream.BitRate, state.OutputVideoBitrate.Value, state.VideoStream == null ? null : state.VideoStream.Codec, state.OutputVideoCodec, @@ -2692,17 +2692,27 @@ namespace MediaBrowser.Api.Playback //inputModifier += " -noaccurate_seek"; } - var videoStream = state.VideoStream; - if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec)) + foreach (var stream in state.MediaSource.MediaStreams) { - inputModifier += " -codec:0 " + videoStream.Codec; - - var audioStream = state.AudioStream; - if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec)) + if (!stream.IsExternal && stream.Type != MediaStreamType.Subtitle) { - inputModifier += " -codec:1 " + audioStream.Codec; + if (!string.IsNullOrWhiteSpace(stream.Codec) && stream.Index != -1) + { + inputModifier += " -codec:" + stream.Index.ToString(UsCulture) + " " + stream.Codec; + } } } + //var videoStream = state.VideoStream; + //if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec)) + //{ + // inputModifier += " -codec:0 " + videoStream.Codec; + + // var audioStream = state.AudioStream; + // if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec)) + // { + // inputModifier += " -codec:1 " + audioStream.Codec; + // } + //} } return inputModifier;