From fcd15da1e6fb6e940f55c2def0e00554feae36e0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 7 Feb 2016 16:48:08 -0500 Subject: [PATCH] update progressive encoding --- .../Playback/BaseStreamingService.cs | 18 ++++++------------ .../Playback/Dash/MpegDashService.cs | 2 +- .../Playback/Hls/DynamicHlsService.cs | 2 +- .../Playback/Hls/VideoHlsService.cs | 2 +- .../Playback/Progressive/VideoService.cs | 2 +- .../Encoder/BaseEncoder.cs | 18 ++++++------------ .../Encoder/VideoEncoder.cs | 2 +- 7 files changed, 17 insertions(+), 29 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index bb7f6bb1e9..bae8074fd4 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -305,9 +305,8 @@ namespace MediaBrowser.Api.Playback /// /// The state. /// The video codec. - /// if set to true [is HLS]. /// System.String. - protected string GetVideoQualityParam(StreamState state, string videoCodec, bool isHls) + protected string GetVideoQualityParam(StreamState state, string videoCodec) { var param = string.Empty; @@ -385,7 +384,7 @@ namespace MediaBrowser.Api.Playback param = "-mbd 2"; } - param += GetVideoBitrateParam(state, videoCodec, isHls); + param += GetVideoBitrateParam(state, videoCodec); var framerate = GetFramerateParam(state); if (framerate.HasValue) @@ -1190,7 +1189,7 @@ namespace MediaBrowser.Api.Playback return bitrate; } - protected string GetVideoBitrateParam(StreamState state, string videoCodec, bool isHls) + protected string GetVideoBitrateParam(StreamState state, string videoCodec) { var bitrate = state.OutputVideoBitrate; @@ -1209,14 +1208,9 @@ namespace MediaBrowser.Api.Playback } // h264 - if (isHls) - { - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", - bitrate.Value.ToString(UsCulture), - (bitrate.Value * 2).ToString(UsCulture)); - } - - return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); + return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); } return string.Empty; diff --git a/MediaBrowser.Api/Playback/Dash/MpegDashService.cs b/MediaBrowser.Api/Playback/Dash/MpegDashService.cs index 9ec16fcc78..defb2eef0d 100644 --- a/MediaBrowser.Api/Playback/Dash/MpegDashService.cs +++ b/MediaBrowser.Api/Playback/Dash/MpegDashService.cs @@ -430,7 +430,7 @@ namespace MediaBrowser.Api.Playback.Dash var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream; - args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg; + args += " " + GetVideoQualityParam(state, GetH264Encoder(state)) + keyFrameArg; // Add resolution params, if specified if (!hasGraphicalSubs) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index baf662c34c..4a83615b4d 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -822,7 +822,7 @@ namespace MediaBrowser.Api.Playback.Hls var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream; - args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg; + args += " " + GetVideoQualityParam(state, GetH264Encoder(state)) + keyFrameArg; //args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0"; diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index be1db1a4df..22c38009a6 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Api.Playback.Hls var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream; - args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg; + args += " " + GetVideoQualityParam(state, GetH264Encoder(state)) + keyFrameArg; // Add resolution params, if specified if (!hasGraphicalSubs) diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 19e568ec47..eaf65bd6b6 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -166,7 +166,7 @@ namespace MediaBrowser.Api.Playback.Progressive args += GetOutputSizeParam(state, videoCodec); } - var qualityParam = GetVideoQualityParam(state, videoCodec, false); + var qualityParam = GetVideoQualityParam(state, videoCodec); if (!string.IsNullOrEmpty(qualityParam)) { diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 3a4a12b354..4fabed850c 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -568,9 +568,8 @@ namespace MediaBrowser.MediaEncoding.Encoder /// /// The state. /// The video codec. - /// if set to true [is HLS]. /// System.String. - protected string GetVideoQualityParam(EncodingJob state, string videoCodec, bool isHls) + protected string GetVideoQualityParam(EncodingJob state, string videoCodec) { var param = string.Empty; @@ -648,7 +647,7 @@ namespace MediaBrowser.MediaEncoding.Encoder param = "-mbd 2"; } - param += GetVideoBitrateParam(state, videoCodec, isHls); + param += GetVideoBitrateParam(state, videoCodec); var framerate = GetFramerateParam(state); if (framerate.HasValue) @@ -718,7 +717,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return "-pix_fmt yuv420p " + param; } - protected string GetVideoBitrateParam(EncodingJob state, string videoCodec, bool isHls) + protected string GetVideoBitrateParam(EncodingJob state, string videoCodec) { var bitrate = state.OutputVideoBitrate; @@ -737,14 +736,9 @@ namespace MediaBrowser.MediaEncoding.Encoder } // h264 - if (isHls) - { - return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", - bitrate.Value.ToString(UsCulture), - (bitrate.Value * 2).ToString(UsCulture)); - } - - return string.Format(" -b:v {0}", bitrate.Value.ToString(UsCulture)); + return string.Format(" -b:v {0} -maxrate {0} -bufsize {1}", + bitrate.Value.ToString(UsCulture), + (bitrate.Value * 2).ToString(UsCulture)); } return string.Empty; diff --git a/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs index 79f248468c..5756566fe9 100644 --- a/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/VideoEncoder.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.MediaEncoding.Encoder args += GetOutputSizeParam(state, videoCodec); } - var qualityParam = GetVideoQualityParam(state, videoCodec, false); + var qualityParam = GetVideoQualityParam(state, videoCodec); if (!string.IsNullOrEmpty(qualityParam)) {