From a38086126fc08bc64e9c73a259334807614ec874 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Apr 2016 14:51:47 -0400 Subject: update hls playback --- MediaBrowser.Model/Dlna/TranscodingProfile.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'MediaBrowser.Model/Dlna/TranscodingProfile.cs') diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs index bf6bf092f..e59ee6d63 100644 --- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs @@ -35,9 +35,6 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("context")] public EncodingContext Context { get; set; } - [XmlAttribute("forceLiveStream")] - public bool ForceLiveStream { get; set; } - public List GetAudioCodecs() { List list = new List(); -- cgit v1.2.3 From c59b4329f4e152be0d186f4db720333fb7b2c4b7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 21 Apr 2016 00:04:57 -0400 Subject: restore ForceLiveStream param --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 1 + MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 13 ++---- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 47 +++++++++++----------- MediaBrowser.Api/Playback/StreamRequest.cs | 2 + MediaBrowser.Model/Dlna/StreamBuilder.cs | 1 + MediaBrowser.Model/Dlna/StreamInfo.cs | 4 +- MediaBrowser.Model/Dlna/TranscodingProfile.cs | 5 ++- 7 files changed, 37 insertions(+), 36 deletions(-) (limited to 'MediaBrowser.Model/Dlna/TranscodingProfile.cs') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 4b05a5ee6..901554973 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -2058,6 +2058,7 @@ namespace MediaBrowser.Api.Playback if (state.VideoRequest != null) { state.VideoRequest.CopyTimestamps = transcodingProfile.CopyTimestamps; + state.VideoRequest.ForceLiveStream = transcodingProfile.ForceLiveStream; } } } diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 49d3c37ea..49f50735f 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -282,19 +282,12 @@ namespace MediaBrowser.Api.Playback.Hls { var isLiveStream = (state.RunTimeTicks ?? 0) == 0; - return isLiveStream; - } - - protected override bool CanStreamCopyAudio(StreamState state, List supportedAudioCodecs) - { - var isLiveStream = IsLiveStream(state); - - if (!isLiveStream) + if (state.VideoRequest.ForceLiveStream) { - return false; + return true; } - return base.CanStreamCopyAudio(state, supportedAudioCodecs); + return isLiveStream; } } } \ No newline at end of file diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 7ed8a9490..f857a43e4 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -500,13 +500,6 @@ namespace MediaBrowser.Api.Playback.Hls return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary()); } - private bool IsLiveStream(StreamState state) - { - var isLiveStream = (state.RunTimeTicks ?? 0) == 0; - - return isLiveStream; - } - private string GetMasterPlaylistFileText(StreamState state, int totalBitrate) { var builder = new StringBuilder(); @@ -828,7 +821,7 @@ namespace MediaBrowser.Api.Playback.Hls args += " -bsf:v h264_mp4toannexb"; } - args += " -flags -global_header -sc_threshold 0"; + args += " -flags -global_header"; } else { @@ -853,7 +846,7 @@ namespace MediaBrowser.Api.Playback.Hls args += GetGraphicalSubtitleParam(state, codec); } - args += " -flags -global_header -sc_threshold 0"; + args += " -flags -global_header"; } if (EnableCopyTs(state) && args.IndexOf("-copyts", StringComparison.OrdinalIgnoreCase) == -1) @@ -866,6 +859,7 @@ namespace MediaBrowser.Api.Playback.Hls private bool EnableCopyTs(StreamState state) { + //return state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Encode; return true; } @@ -888,21 +882,26 @@ namespace MediaBrowser.Api.Playback.Hls var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty; - //var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state); - - //return string.Format("{0} {10} {1} -map_metadata -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", - // inputModifier, - // GetInputArgument(state), - // threads, - // mapArgs, - // GetVideoArguments(state), - // GetAudioArguments(state), - // state.SegmentLength.ToString(UsCulture), - // startNumberParam, - // outputPath, - // outputTsArg, - // toTimeParam - // ).Trim(); + var enableGenericSegmenter = false; + + if (enableGenericSegmenter) + { + var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state); + + return string.Format("{0} {10} {1} -map_metadata -1 -threads {2} {3} {4} {5} -f segment -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -segment_time {6} -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", + inputModifier, + GetInputArgument(state), + threads, + mapArgs, + GetVideoArguments(state), + GetAudioArguments(state), + state.SegmentLength.ToString(UsCulture), + startNumberParam, + outputPath, + outputTsArg, + toTimeParam + ).Trim(); + } return string.Format("{0}{11} {1} -map_metadata -1 -threads {2} {3} {4}{5} {6} -max_delay 5000000 -avoid_negative_ts disabled -start_at_zero -hls_time {7} -start_number {8} -hls_list_size {9} -y \"{10}\"", inputModifier, diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 14fdb1197..371dbbda2 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -190,6 +190,8 @@ namespace MediaBrowser.Api.Playback [ApiMember(Name = "CopyTimestamps", Description = "Whether or not to copy timestamps when transcoding with an offset. Defaults to false.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool CopyTimestamps { get; set; } + public bool ForceLiveStream { get; set; } + public VideoStreamRequest() { EnableAutoStreamCopy = true; diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index f44f89f22..1e6b7c729 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -443,6 +443,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.VideoCodec = transcodingProfile.VideoCodec; playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps; + playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream; playlistItem.SubProtocol = transcodingProfile.Protocol; playlistItem.AudioStreamIndex = audioStreamIndex; diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index a2867dcc9..644f732a7 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -31,6 +31,7 @@ namespace MediaBrowser.Model.Dlna public string VideoProfile { get; set; } public bool CopyTimestamps { get; set; } + public bool ForceLiveStream { get; set; } public string AudioCodec { get; set; } public int? AudioStreamIndex { get; set; } @@ -204,7 +205,7 @@ namespace MediaBrowser.Model.Dlna list.Add(new NameValuePair("MaxWidth", item.MaxWidth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxWidth.Value) : string.Empty)); list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty)); - if (StringHelper.EqualsIgnoreCase(item.SubProtocol, "hls")) + if (StringHelper.EqualsIgnoreCase(item.SubProtocol, "hls") && !item.ForceLiveStream) { list.Add(new NameValuePair("StartTimeTicks", string.Empty)); } @@ -234,6 +235,7 @@ namespace MediaBrowser.Model.Dlna } list.Add(new NameValuePair("CopyTimestamps", item.CopyTimestamps.ToString().ToLower())); + list.Add(new NameValuePair("ForceLiveStream", item.ForceLiveStream.ToString().ToLower())); list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty)); return list; diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs index e59ee6d63..36c357926 100644 --- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("protocol")] public string Protocol { get; set; } - + [XmlAttribute("estimateContentLength")] public bool EstimateContentLength { get; set; } @@ -35,6 +35,9 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("context")] public EncodingContext Context { get; set; } + [XmlAttribute("forceLiveStream")] + public bool ForceLiveStream { get; set; } + public List GetAudioCodecs() { List list = new List(); -- cgit v1.2.3 From 187b1099bc0ce50b8b2bef8ff37fa4be6e1b3739 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 May 2016 01:40:01 -0400 Subject: update firefox profile --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 21 +++++++++++++++++---- MediaBrowser.Api/Playback/StreamRequest.cs | 4 +++- MediaBrowser.Model/Dlna/StreamBuilder.cs | 9 +++++++++ MediaBrowser.Model/Dlna/StreamInfo.cs | 5 ++++- MediaBrowser.Model/Dlna/TranscodingProfile.cs | 3 +++ 5 files changed, 36 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Model/Dlna/TranscodingProfile.cs') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 800f246c4..792e46842 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -712,15 +712,16 @@ namespace MediaBrowser.Api.Playback inputChannels = null; } + int? resultChannels = null; var codec = outputAudioCodec ?? string.Empty; if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1) { // wmav2 currently only supports two channel output - return Math.Min(2, inputChannels ?? 2); + resultChannels = Math.Min(2, inputChannels ?? 2); } - if (request.MaxAudioChannels.HasValue) + else if (request.MaxAudioChannels.HasValue) { var channelLimit = codec.IndexOf("mp3", StringComparison.OrdinalIgnoreCase) != -1 ? 2 @@ -732,10 +733,18 @@ namespace MediaBrowser.Api.Playback } // If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels - return Math.Min(request.MaxAudioChannels.Value, channelLimit); + resultChannels = Math.Min(request.MaxAudioChannels.Value, channelLimit); } - return request.AudioChannels; + if (resultChannels.HasValue && !string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) + { + if (request.TranscodingMaxAudioChannels.HasValue) + { + resultChannels = Math.Min(request.TranscodingMaxAudioChannels.Value, resultChannels.Value); + } + } + + return resultChannels ?? request.AudioChannels; } /// @@ -1504,6 +1513,10 @@ namespace MediaBrowser.Api.Playback } } } + else if (i == 26) + { + request.TranscodingMaxAudioChannels = int.Parse(val, UsCulture); + } } } diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 371dbbda2..370915ec3 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -51,7 +51,9 @@ namespace MediaBrowser.Api.Playback [ApiMember(Name = "MaxAudioChannels", Description = "Optional. Specify a maximum number of audio channels to encode to, e.g. 2", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? MaxAudioChannels { get; set; } - + + public int? TranscodingMaxAudioChannels { get; set; } + /// /// Gets or sets the audio sample rate. /// diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 07a4b8995..7721bfd15 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -459,6 +459,15 @@ namespace MediaBrowser.Model.Dlna playlistItem.VideoCodec = transcodingProfile.VideoCodec; playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps; playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream; + + if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels)) + { + int transcodingMaxAudioChannels; + if (IntHelper.TryParseCultureInvariant(transcodingProfile.MaxAudioChannels, out transcodingMaxAudioChannels)) + { + playlistItem.TranscodingMaxAudioChannels = transcodingMaxAudioChannels; + } + } playlistItem.SubProtocol = transcodingProfile.Protocol; playlistItem.AudioStreamIndex = audioStreamIndex; diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 644f732a7..313c30e2c 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -38,6 +38,7 @@ namespace MediaBrowser.Model.Dlna public int? SubtitleStreamIndex { get; set; } + public int? TranscodingMaxAudioChannels { get; set; } public int? MaxAudioChannels { get; set; } public int? AudioBitrate { get; set; } @@ -237,7 +238,9 @@ namespace MediaBrowser.Model.Dlna list.Add(new NameValuePair("CopyTimestamps", item.CopyTimestamps.ToString().ToLower())); list.Add(new NameValuePair("ForceLiveStream", item.ForceLiveStream.ToString().ToLower())); list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty)); - + + list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.TranscodingMaxAudioChannels.Value) : string.Empty)); + return list; } diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs index 36c357926..d1314c17b 100644 --- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs @@ -38,6 +38,9 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("forceLiveStream")] public bool ForceLiveStream { get; set; } + [XmlAttribute("maxAudioChannels")] + public string MaxAudioChannels { get; set; } + public List GetAudioCodecs() { List list = new List(); -- cgit v1.2.3