diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-03-28 11:58:59 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-03-28 11:58:59 -0400 |
| commit | 7eabf7e0153d4b3574c44c72d2a8c2a14d867bc2 (patch) | |
| tree | f0fd89c819bd5ab1dee2b1fd9d245836f68da5f9 | |
| parent | 18ff0098741ee158ac38407e16131d00a98a3412 (diff) | |
| parent | 20428bfdaf347e11bb15998895a4e3d395b2826b (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Progressive/VideoService.cs | 82 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/StreamRequest.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs | 6 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Common.Internal.nuspec | 4 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Common.nuspec | 2 | ||||
| -rw-r--r-- | Nuget/MediaBrowser.Server.Core.nuspec | 4 |
8 files changed, 83 insertions, 52 deletions
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 600412986..b1879b8d2 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -178,9 +178,7 @@ namespace MediaBrowser.Api.Playback.Hls var probeSize = Kernel.Instance.FFMpegManager.GetProbeSizeArgument(state.Item); - const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+5))"; - - return string.Format("{0} {1} -i {2}{3} -threads 0 {4} {5} {6}{7} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{8}\" \"{9}\"", + return string.Format("{0} {1} -i {2}{3} -threads 0 {4} {5} {6} -f ssegment -segment_list_flags +live -segment_time 10 -segment_list \"{7}\" \"{8}\"", probeSize, GetFastSeekCommandLineParameter(state.Request), GetInputArgument(state.Item, state.IsoMount), @@ -188,7 +186,6 @@ namespace MediaBrowser.Api.Playback.Hls GetMapArgs(state), GetVideoArguments(state), GetAudioArguments(state), - keyFrameArg, outputPath, segmentOutputPath ).Trim(); diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 699d45de3..eb72f27d4 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -8,14 +8,14 @@ using ServiceStack.ServiceHost; namespace MediaBrowser.Api.Playback.Hls { [Route("/Videos/{Id}/stream.m3u8", "GET")] - [ServiceStack.ServiceHost.Api(Description = "Gets a video stream using HTTP live streaming.")] + [Api(Description = "Gets a video stream using HTTP live streaming.")] public class GetHlsVideoStream : VideoStreamRequest { } [Route("/Videos/{Id}/segments/{SegmentId}/stream.ts", "GET")] - [ServiceStack.ServiceHost.Api(Description = "Gets an Http live streaming segment file. Internal use only.")] + [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsVideoSegment { public string Id { get; set; } @@ -115,7 +115,9 @@ namespace MediaBrowser.Api.Playback.Hls return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf h264_mp4toannexb" : "-codec:v:0 copy"; } - var args = "-codec:v:0 " + codec + " -preset superfast"; + const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+5))"; + + var args = "-codec:v:0 " + codec + " -preset superfast" + keyFrameArg; if (state.VideoRequest.VideoBitRate.HasValue) { @@ -154,6 +156,16 @@ namespace MediaBrowser.Api.Playback.Hls args += " -vsync vfr"; + if (!string.IsNullOrEmpty(state.VideoRequest.Profile)) + { + args += " -profile:v" + state.VideoRequest.Profile; + } + + if (!string.IsNullOrEmpty(state.VideoRequest.Level)) + { + args += " -level 3" + state.VideoRequest.Level; + } + if (state.SubtitleStream != null) { // This is for internal graphical subs diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 7a490cc70..b30a14ecc 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -81,17 +81,6 @@ namespace MediaBrowser.Api.Playback.Progressive // Get the output codec name var videoCodec = GetVideoCodec(state.VideoRequest); - var graphicalSubtitleParam = string.Empty; - - if (state.SubtitleStream != null) - { - // This is for internal graphical subs - if (!state.SubtitleStream.IsExternal && (state.SubtitleStream.Codec.IndexOf("pgs", StringComparison.OrdinalIgnoreCase) != -1 || state.SubtitleStream.Codec.IndexOf("dvd", StringComparison.OrdinalIgnoreCase) != -1)) - { - graphicalSubtitleParam = GetInternalGraphicalSubtitleParam(state, videoCodec); - } - } - var format = string.Empty; var keyFrame = string.Empty; @@ -106,7 +95,7 @@ namespace MediaBrowser.Api.Playback.Progressive keyFrame = " -g " + Math.Round(framerate); } - return string.Format("{0} {1} -i {2}{3}{4} -threads 0 {5} {6}{7} {8}{9} \"{10}\"", + return string.Format("{0} {1} -i {2}{3}{4} -threads 0 {5} {6} {7}{8} \"{9}\"", probeSize, GetFastSeekCommandLineParameter(state.Request), GetInputArgument(video, state.IsoMount), @@ -114,7 +103,6 @@ namespace MediaBrowser.Api.Playback.Progressive keyFrame, GetMapArgs(state), GetVideoArguments(state, videoCodec), - graphicalSubtitleParam, GetAudioArguments(state), format, outputPath @@ -125,42 +113,62 @@ namespace MediaBrowser.Api.Playback.Progressive /// Gets video arguments to pass to ffmpeg /// </summary> /// <param name="state">The state.</param> - /// <param name="videoCodec">The video codec.</param> + /// <param name="codec">The video codec.</param> /// <returns>System.String.</returns> - private string GetVideoArguments(StreamState state, string videoCodec) + private string GetVideoArguments(StreamState state, string codec) { - var args = "-vcodec " + videoCodec; + var args = "-vcodec " + codec; + + // See if we can save come cpu cycles by avoiding encoding + if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) + { + return IsH264(state.VideoStream) ? args + " -bsf h264_mp4toannexb" : args; + } + + const string keyFrameArg = " -force_key_frames expr:if(isnan(prev_forced_t),gte(t,0),gte(t,prev_forced_t+2))"; + + args += keyFrameArg; var request = state.VideoRequest; - // If we're encoding video, add additional params - if (!videoCodec.Equals("copy", StringComparison.OrdinalIgnoreCase)) + // Add resolution params, if specified + if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue) { - // Add resolution params, if specified - if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue) - { - args += GetOutputSizeParam(state, videoCodec); - } + args += GetOutputSizeParam(state, codec); + } - if (request.Framerate.HasValue) - { - args += string.Format(" -r {0}", request.Framerate.Value); - } + if (request.Framerate.HasValue) + { + args += string.Format(" -r {0}", request.Framerate.Value); + } - // Add the audio bitrate - var qualityParam = GetVideoQualityParam(request, videoCodec); + // Add the audio bitrate + var qualityParam = GetVideoQualityParam(request, codec); - if (!string.IsNullOrEmpty(qualityParam)) - { - args += " " + qualityParam; - } + if (!string.IsNullOrEmpty(qualityParam)) + { + args += " " + qualityParam; + } - args += " -vsync vfr"; + args += " -vsync vfr"; + + if (!string.IsNullOrEmpty(state.VideoRequest.Profile)) + { + args += " -profile:v" + state.VideoRequest.Profile; } - else if (IsH264(state.VideoStream)) + + if (!string.IsNullOrEmpty(state.VideoRequest.Level)) + { + args += " -level 3" + state.VideoRequest.Level; + } + + if (state.SubtitleStream != null) { - // FFmpeg will fail to convert and give h264 bitstream malformated error if it isn't used when converting mp4 to transport stream. - args += " -bsf h264_mp4toannexb"; + // This is for internal graphical subs + if (!state.SubtitleStream.IsExternal && (state.SubtitleStream.Codec.IndexOf("pgs", StringComparison.OrdinalIgnoreCase) != -1 || state.SubtitleStream.Codec.IndexOf("dvd", StringComparison.OrdinalIgnoreCase) != -1)) + { + args += GetInternalGraphicalSubtitleParam(state, codec); + } } return args; diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index a0b0a1a72..d4da11e3f 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -135,5 +135,19 @@ namespace MediaBrowser.Api.Playback /// <value>The framerate.</value> [ApiMember(Name = "Framerate", Description = "Optional. A specific video framerate to encode to, e.g. 23.976. Generally this should be omitted unless the device has specific requirements.", IsRequired = false, DataType = "double", ParameterType = "query", Verb = "GET")] public double? Framerate { get; set; } + + /// <summary> + /// Gets or sets the profile. + /// </summary> + /// <value>The profile.</value> + [ApiMember(Name = "Profile", Description = "Optional. Specify a specific h264 profile, e.g. main, baseline, high.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Profile { get; set; } + + /// <summary> + /// Gets or sets the level. + /// </summary> + /// <value>The level.</value> + [ApiMember(Name = "Level", Description = "Optional. Specify a level for the h264 profile, e.g. 3, 3.1.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Level { get; set; } } } diff --git a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs index 2ee3193dc..50d625739 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs +++ b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs @@ -88,13 +88,13 @@ namespace MediaBrowser.ServerApplication.EntryPoints void _taskManager_TaskCompleted(object sender, GenericEventArgs<TaskResult> e) { - _serverManager.SendWebSocketMessage("ScheduledTaskEndExecute", e.Argument); + _serverManager.SendWebSocketMessage("ScheduledTaskEnded", e.Argument); } void _taskManager_TaskExecuting(object sender, EventArgs e) { var task = (IScheduledTask) sender; - _serverManager.SendWebSocketMessage("ScheduledTaskBeginExecute", task.Name); + _serverManager.SendWebSocketMessage("ScheduledTaskStarted", task.Name); } /// <summary> @@ -164,7 +164,7 @@ namespace MediaBrowser.ServerApplication.EntryPoints /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void kernel_HasPendingRestartChanged(object sender, EventArgs e) { - _serverManager.SendWebSocketMessage("HasPendingRestartChanged", _appHost.GetSystemInfo()); + _serverManager.SendWebSocketMessage("RestartRequired", _appHost.GetSystemInfo()); } /// <summary> diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 19b811fe9..fbbddc5f3 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <metadata> <id>MediaBrowser.Common.Internal</id> - <version>3.0.61</version> + <version>3.0.62</version> <title>MediaBrowser.Common.Internal</title> <authors>Luke</authors> <owners>ebr,Luke,scottisafool</owners> @@ -12,7 +12,7 @@ <description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description> <copyright>Copyright © Media Browser 2013</copyright> <dependencies> - <dependency id="MediaBrowser.Common" version="3.0.61" /> + <dependency id="MediaBrowser.Common" version="3.0.62" /> <dependency id="NLog" version="2.0.0.2000" /> <dependency id="ServiceStack.Text" version="3.9.38" /> <dependency id="protobuf-net" version="2.0.0.621" /> diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 78a4fbbad..34c9463da 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>MediaBrowser.Common</id> - <version>3.0.61</version> + <version>3.0.62</version> <title>MediaBrowser.Common</title> <authors>Media Browser Team</authors> <owners>ebr,Luke,scottisafool</owners> diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 4a9693e7f..0d554fb46 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <id>MediaBrowser.Server.Core</id> - <version>3.0.61</version> + <version>3.0.62</version> <title>Media Browser.Server.Core</title> <authors>Media Browser Team</authors> <owners>ebr,Luke,scottisafool</owners> @@ -12,7 +12,7 @@ <description>Contains core components required to build plugins for Media Browser Server.</description> <copyright>Copyright © Media Browser 2013</copyright> <dependencies> - <dependency id="MediaBrowser.Common" version="3.0.61" /> + <dependency id="MediaBrowser.Common" version="3.0.62" /> </dependencies> </metadata> <files> |
