|
|
@ -130,7 +130,6 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
|
|
|
|
|
|
|
|
data += "-" + (state.Request.DeviceId ?? string.Empty);
|
|
|
|
data += "-" + (state.Request.DeviceId ?? string.Empty);
|
|
|
|
data += "-" + (state.Request.PlaySessionId ?? string.Empty);
|
|
|
|
data += "-" + (state.Request.PlaySessionId ?? string.Empty);
|
|
|
|
data += "-" + (state.Request.ClientTime ?? string.Empty);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataHash = data.GetMD5().ToString("N");
|
|
|
|
var dataHash = data.GetMD5().ToString("N");
|
|
|
|
|
|
|
|
|
|
|
@ -287,14 +286,20 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
return threads;
|
|
|
|
return threads;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected string H264Encoder
|
|
|
|
protected string GetH264Encoder(StreamState state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get
|
|
|
|
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "libx264";
|
|
|
|
// It's currently failing on live tv
|
|
|
|
|
|
|
|
if (state.RunTimeTicks.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return "h264_qsv";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "libx264";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the video bitrate to specify on the command line
|
|
|
|
/// Gets the video bitrate to specify on the command line
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -313,7 +318,7 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
param = "-preset superfast";
|
|
|
|
param = "-preset superfast";
|
|
|
|
|
|
|
|
|
|
|
|
param += " -crf 23";
|
|
|
|
param += " -crf 23 -rc-lookahead 0 -muxdelay 0 -refs 1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
|
|
|
|
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
|
|
|
@ -326,7 +331,7 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
// h264 (h264_qsv)
|
|
|
|
// h264 (h264_qsv)
|
|
|
|
else if (string.Equals(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
else if (string.Equals(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
param = "-preset 7";
|
|
|
|
param = "-preset 7 -look_ahead 0";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -400,8 +405,10 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(state.VideoRequest.Level))
|
|
|
|
if (!string.IsNullOrEmpty(state.VideoRequest.Level))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
var h264Encoder = GetH264Encoder(state);
|
|
|
|
|
|
|
|
|
|
|
|
// h264_qsv and libnvenc expect levels to be expressed as a decimal. libx264 supports decimal and non-decimal format
|
|
|
|
// h264_qsv and libnvenc expect levels to be expressed as a decimal. libx264 supports decimal and non-decimal format
|
|
|
|
if (String.Equals(H264Encoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) || String.Equals(H264Encoder, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (String.Equals(h264Encoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) || String.Equals(h264Encoder, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (state.VideoRequest.Level)
|
|
|
|
switch (state.VideoRequest.Level)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -561,7 +568,10 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
|
|
|
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
filters[filters.Count - 1] += ":flags=fast_bilinear";
|
|
|
|
if (filters.Count > 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//filters[filters.Count - 1] += ":flags=fast_bilinear";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var output = string.Empty;
|
|
|
|
var output = string.Empty;
|
|
|
@ -782,7 +792,7 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return H264Encoder;
|
|
|
|
return GetH264Encoder(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -810,7 +820,7 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
protected string GetVideoDecoder(StreamState state)
|
|
|
|
protected string GetVideoDecoder(StreamState state)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareVideoDecoder, "qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec))
|
|
|
|
if (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1415,50 +1425,46 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 16)
|
|
|
|
else if (i == 16)
|
|
|
|
{
|
|
|
|
|
|
|
|
request.ClientTime = val;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (i == 17)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (videoRequest != null)
|
|
|
|
if (videoRequest != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
videoRequest.MaxRefFrames = int.Parse(val, UsCulture);
|
|
|
|
videoRequest.MaxRefFrames = int.Parse(val, UsCulture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 18)
|
|
|
|
else if (i == 17)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (videoRequest != null)
|
|
|
|
if (videoRequest != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
videoRequest.MaxVideoBitDepth = int.Parse(val, UsCulture);
|
|
|
|
videoRequest.MaxVideoBitDepth = int.Parse(val, UsCulture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 19)
|
|
|
|
else if (i == 18)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (videoRequest != null)
|
|
|
|
if (videoRequest != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
videoRequest.Profile = val;
|
|
|
|
videoRequest.Profile = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 20)
|
|
|
|
else if (i == 19)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (videoRequest != null)
|
|
|
|
if (videoRequest != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
videoRequest.Cabac = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
|
|
|
videoRequest.Cabac = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 21)
|
|
|
|
else if (i == 20)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
request.PlaySessionId = val;
|
|
|
|
request.PlaySessionId = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 22)
|
|
|
|
else if (i == 21)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// api_key
|
|
|
|
// api_key
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 23)
|
|
|
|
else if (i == 22)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
request.LiveStreamId = val;
|
|
|
|
request.LiveStreamId = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i == 24)
|
|
|
|
else if (i == 23)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Duplicating ItemId because of MediaMonkey
|
|
|
|
// Duplicating ItemId because of MediaMonkey
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1662,7 +1668,6 @@ namespace MediaBrowser.Api.Playback
|
|
|
|
state.InputContainer = mediaSource.Container;
|
|
|
|
state.InputContainer = mediaSource.Container;
|
|
|
|
state.InputFileSize = mediaSource.Size;
|
|
|
|
state.InputFileSize = mediaSource.Size;
|
|
|
|
state.InputBitrate = mediaSource.Bitrate;
|
|
|
|
state.InputBitrate = mediaSource.Bitrate;
|
|
|
|
state.ReadInputAtNativeFramerate = mediaSource.ReadAtNativeFramerate;
|
|
|
|
|
|
|
|
state.RunTimeTicks = mediaSource.RunTimeTicks;
|
|
|
|
state.RunTimeTicks = mediaSource.RunTimeTicks;
|
|
|
|
state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
|
|
|
|
state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
|
|
|
|
|
|
|
|
|
|
|
|