The Free Software Media System - Server Backend & API
#73 - added audio/video sync
LukePulverenti095896fa4999
diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.csindex 578eb93ac0..62ed0f35f9 100644--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs@@ -56,13 +56,13 @@ namespace MediaBrowser.Api.Playback.Hls/// <returns>System.String.</returns>protected override string GetAudioArguments(StreamState state){- if (!state.Request.AudioCodec.HasValue)+ var codec = GetAudioCodec(state.Request);++ if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)){return "-codec:a:0 copy";}- var codec = GetAudioCodec(state.Request);-var args = "-codec:a:0 " + codec;if (state.AudioStream != null)@@ -84,6 +84,8 @@ namespace MediaBrowser.Api.Playback.Hlsargs += " -ab " + state.Request.AudioBitRate.Value;}+ args += " -af \"aresample=async=1000\"";+return args;}@@ -99,12 +101,6 @@ namespace MediaBrowser.Api.Playback.Hls{var codec = GetVideoCodec(state.VideoRequest);- // Right now all we support is either h264 or copy- if (!codec.Equals("copy", StringComparison.OrdinalIgnoreCase) && !codec.Equals("libx264", StringComparison.OrdinalIgnoreCase))- {- codec = "libx264";- }-// See if we can save come cpu cycles by avoiding encodingif (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)){@@ -125,7 +121,7 @@ namespace MediaBrowser.Api.Playback.Hls}// Get the output framerate based on the FrameRate param- double framerate = state.VideoRequest.Framerate ?? 0;+ var framerate = state.VideoRequest.Framerate ?? 0;// We have to supply a framerate for hls, so if it's null, account for that hereif (framerate.Equals(0))@@ -146,6 +142,9 @@ namespace MediaBrowser.Api.Playback.Hls// Needed to ensure segments stay under 10 secondsargs += string.Format(" -g {0}", framerate);+ args += " -vsync vfr";++return args;}diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.csindex 0e94b7df89..f545c00051 100644--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs@@ -154,6 +154,8 @@ namespace MediaBrowser.Api.Playback.Progressive{args += " " + qualityParam;}++ args += " -vsync vfr";}else if (IsH264(state.VideoStream)){