diff options
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/ItemUpdateService.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 86 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/VideoService.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamRequest.cs | 1 |
5 files changed, 57 insertions, 36 deletions
diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index b0a0e79ae..5c99d98c2 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -99,6 +99,7 @@ namespace MediaBrowser.Api var path = item.ContainingFolderPath; var types = _config.Configuration.ContentTypes + .Where(i => !string.IsNullOrWhiteSpace(i.Name)) .Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase)) .ToList(); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6545d995c..7f568183e 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -870,33 +870,47 @@ namespace MediaBrowser.Api.Playback inputChannels = null; } - int? resultChannels = null; + int? transcoderChannelLimit = null; var codec = outputAudioCodec ?? string.Empty; if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1) { // wmav2 currently only supports two channel output - resultChannels = Math.Min(2, inputChannels ?? 2); + transcoderChannelLimit = 2; } - else if (request.MaxAudioChannels.HasValue) + else if (codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1) + { + // libmp3lame currently only supports two channel output + transcoderChannelLimit = 2; + } + else { - var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1 - ? 2 - : 6; + // If we don't have any media info then limit it to 6 to prevent encoding errors due to asking for too many channels + transcoderChannelLimit = 6; + } - if (inputChannels.HasValue) - { - channelLimit = Math.Min(channelLimit, inputChannels.Value); - } + var isTranscodingAudio = !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase); + + int? resultChannels = null; + if (isTranscodingAudio) + { + resultChannels = request.TranscodingMaxAudioChannels; + } + resultChannels = resultChannels ?? request.MaxAudioChannels ?? request.AudioChannels; - // If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels - resultChannels = Math.Min(request.MaxAudioChannels.Value, channelLimit); + if (inputChannels.HasValue) + { + resultChannels = resultChannels.HasValue + ? Math.Min(resultChannels.Value, inputChannels.Value) + : inputChannels.Value; } - if (request.TranscodingMaxAudioChannels.HasValue && !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) + if (isTranscodingAudio && transcoderChannelLimit.HasValue) { - resultChannels = Math.Min(request.TranscodingMaxAudioChannels.Value, resultChannels ?? inputChannels ?? request.TranscodingMaxAudioChannels.Value); + resultChannels = resultChannels.HasValue + ? Math.Min(resultChannels.Value, transcoderChannelLimit.Value) + : transcoderChannelLimit.Value; } return resultChannels ?? request.AudioChannels; @@ -1054,7 +1068,19 @@ namespace MediaBrowser.Api.Playback arg += string.Format(" -canvas_size {0}:{1}", state.VideoStream.Width.Value.ToString(CultureInfo.InvariantCulture), Convert.ToInt32(height).ToString(CultureInfo.InvariantCulture)); } - arg += " -i \"" + state.SubtitleStream.Path + "\""; + + var subtitlePath = state.SubtitleStream.Path; + + if (string.Equals(Path.GetExtension(subtitlePath), ".sub", StringComparison.OrdinalIgnoreCase)) + { + var idxFile = Path.ChangeExtension(subtitlePath, ".idx"); + if (FileSystem.FileExists(idxFile)) + { + subtitlePath = idxFile; + } + } + + arg += " -i \"" + subtitlePath + "\""; } } @@ -1467,7 +1493,7 @@ namespace MediaBrowser.Api.Playback } // h264 - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + return string.Format(" -maxrate {0} -bufsize {1}", bitrate.Value.ToString(UsCulture), (bitrate.Value * 2).ToString(UsCulture)); } @@ -1756,13 +1782,6 @@ namespace MediaBrowser.Api.Playback { if (videoRequest != null) { - videoRequest.EnableSplittingOnNonKeyFrames = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); - } - } - else if (i == 30) - { - if (videoRequest != null) - { videoRequest.RequireAvc = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); } } @@ -1948,10 +1967,15 @@ namespace MediaBrowser.Api.Playback state.OutputVideoCodec = state.VideoRequest.VideoCodec; state.OutputVideoBitrate = GetVideoBitrateParamValue(state.VideoRequest, state.VideoStream, state.OutputVideoCodec); - if (state.OutputVideoBitrate.HasValue) + if (videoRequest != null) + { + TryStreamCopy(state, videoRequest); + } + + 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, @@ -1961,13 +1985,12 @@ namespace MediaBrowser.Api.Playback videoRequest.MaxWidth = resolution.MaxWidth; videoRequest.MaxHeight = resolution.MaxHeight; } - } - ApplyDeviceProfileSettings(state); - - if (videoRequest != null) + ApplyDeviceProfileSettings(state); + } + else { - TryStreamCopy(state, videoRequest); + ApplyDeviceProfileSettings(state); } state.OutputFilePath = GetOutputFilePath(state); @@ -2096,7 +2119,7 @@ namespace MediaBrowser.Api.Playback state.MediaSource = mediaSource; } - protected virtual bool CanStreamCopyVideo(StreamState state) + protected bool CanStreamCopyVideo(StreamState state) { var request = state.VideoRequest; var videoStream = state.VideoStream; @@ -2381,7 +2404,6 @@ namespace MediaBrowser.Api.Playback { state.VideoRequest.CopyTimestamps = transcodingProfile.CopyTimestamps; state.VideoRequest.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest; - state.VideoRequest.EnableSplittingOnNonKeyFrames = transcodingProfile.EnableSplittingOnNonKeyFrames; } } } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index f1b5b4681..171c971f1 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -886,8 +886,7 @@ namespace MediaBrowser.Api.Playback.Hls } var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty; - var enableSplittingOnNonKeyFrames = state.VideoRequest.EnableSplittingOnNonKeyFrames && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase); - enableSplittingOnNonKeyFrames = false; + var enableSplittingOnNonKeyFrames = string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && false; // TODO: check libavformat version for 57 50.100 and use -hls_flags split_by_time var hlsProtocolSupportsSplittingByTime = false; diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index e29aa7d5a..7ae64b834 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -153,7 +153,7 @@ namespace MediaBrowser.Api.Playback.Progressive if (!state.RunTimeTicks.HasValue) { - args += " -fflags +genpts -flags +global_header"; + args += " -flags -global_header -fflags +genpts"; } return args; diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 50c779765..2a2ad92cd 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -194,7 +194,6 @@ namespace MediaBrowser.Api.Playback public bool CopyTimestamps { get; set; } public bool EnableSubtitlesInManifest { get; set; } - public bool EnableSplittingOnNonKeyFrames { get; set; } public bool RequireAvc { get; set; } public VideoStreamRequest() |
