fix stream copy decisions

This commit is contained in:
Luke Pulverenti 2015-09-20 12:42:11 -04:00
parent 4fb8938d09
commit fe430acfc9
2 changed files with 38 additions and 35 deletions

View File

@ -312,31 +312,6 @@ namespace MediaBrowser.Api.Playback.Hls
return 0; return 0;
} }
protected override bool CanStreamCopyVideo(VideoStreamRequest request, MediaStream videoStream)
{
if (videoStream.KeyFrames == null || videoStream.KeyFrames.Count == 0)
{
Logger.Debug("Cannot stream copy video due to missing keyframe info");
return false;
}
var previousSegment = 0;
foreach (var frame in videoStream.KeyFrames)
{
var length = frame - previousSegment;
// Don't allow really long segments because this could result in long download times
if (length > 10000)
{
Logger.Debug("Cannot stream copy video due to long segment length of {0}ms", length);
return false;
}
previousSegment = frame;
}
return base.CanStreamCopyVideo(request, videoStream);
}
protected override bool CanStreamCopyAudio(VideoStreamRequest request, MediaStream audioStream, List<string> supportedAudioCodecs) protected override bool CanStreamCopyAudio(VideoStreamRequest request, MediaStream audioStream, List<string> supportedAudioCodecs)
{ {
return false; return false;

View File

@ -285,6 +285,8 @@ namespace MediaBrowser.Api.Playback.Hls
private double[] GetSegmentLengths(StreamState state) private double[] GetSegmentLengths(StreamState state)
{ {
var result = new List<double>(); var result = new List<double>();
if (state.VideoRequest != null)
{
var encoder = GetVideoEncoder(state); var encoder = GetVideoEncoder(state);
if (string.Equals(encoder, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(encoder, "copy", StringComparison.OrdinalIgnoreCase))
@ -301,6 +303,7 @@ namespace MediaBrowser.Api.Playback.Hls
return result.ToArray(); return result.ToArray();
} }
} }
}
var ticks = state.RunTimeTicks ?? 0; var ticks = state.RunTimeTicks ?? 0;
@ -960,5 +963,30 @@ namespace MediaBrowser.Api.Playback.Hls
{ {
return isOutputVideo ? ".ts" : ".ts"; return isOutputVideo ? ".ts" : ".ts";
} }
protected override bool CanStreamCopyVideo(VideoStreamRequest request, MediaStream videoStream)
{
if (videoStream.KeyFrames == null || videoStream.KeyFrames.Count == 0)
{
Logger.Debug("Cannot stream copy video due to missing keyframe info");
return false;
}
var previousSegment = 0;
foreach (var frame in videoStream.KeyFrames)
{
var length = frame - previousSegment;
// Don't allow really long segments because this could result in long download times
if (length > 10000)
{
Logger.Debug("Cannot stream copy video due to long segment length of {0}ms", length);
return false;
}
previousSegment = frame;
}
return base.CanStreamCopyVideo(request, videoStream);
}
} }
} }