support qsv encoding
This commit is contained in:
parent
b73c3f4411
commit
4415506837
|
@ -130,7 +130,6 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
data += "-" + (state.Request.DeviceId ?? string.Empty);
|
||||
data += "-" + (state.Request.PlaySessionId ?? string.Empty);
|
||||
data += "-" + (state.Request.ClientTime ?? string.Empty);
|
||||
|
||||
var dataHash = data.GetMD5().ToString("N");
|
||||
|
||||
|
@ -287,14 +286,20 @@ namespace MediaBrowser.Api.Playback
|
|||
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>
|
||||
/// Gets the video bitrate to specify on the command line
|
||||
/// </summary>
|
||||
|
@ -313,7 +318,7 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
param = "-preset superfast";
|
||||
|
||||
param += " -crf 23";
|
||||
param += " -crf 23 -rc-lookahead 0 -muxdelay 0 -refs 1";
|
||||
}
|
||||
|
||||
else if (string.Equals(videoCodec, "libx265", StringComparison.OrdinalIgnoreCase))
|
||||
|
@ -326,7 +331,7 @@ namespace MediaBrowser.Api.Playback
|
|||
// h264 (h264_qsv)
|
||||
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))
|
||||
{
|
||||
var h264Encoder = GetH264Encoder(state);
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
@ -561,7 +568,10 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
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;
|
||||
|
@ -782,7 +792,7 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return H264Encoder;
|
||||
return GetH264Encoder(state);
|
||||
}
|
||||
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
@ -810,7 +820,7 @@ namespace MediaBrowser.Api.Playback
|
|||
/// <returns>System.String.</returns>
|
||||
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))
|
||||
{
|
||||
|
@ -1415,50 +1425,46 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
}
|
||||
else if (i == 16)
|
||||
{
|
||||
request.ClientTime = val;
|
||||
}
|
||||
else if (i == 17)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxRefFrames = int.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 18)
|
||||
else if (i == 17)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.MaxVideoBitDepth = int.Parse(val, UsCulture);
|
||||
}
|
||||
}
|
||||
else if (i == 19)
|
||||
else if (i == 18)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.Profile = val;
|
||||
}
|
||||
}
|
||||
else if (i == 20)
|
||||
else if (i == 19)
|
||||
{
|
||||
if (videoRequest != null)
|
||||
{
|
||||
videoRequest.Cabac = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
else if (i == 21)
|
||||
else if (i == 20)
|
||||
{
|
||||
request.PlaySessionId = val;
|
||||
}
|
||||
else if (i == 22)
|
||||
else if (i == 21)
|
||||
{
|
||||
// api_key
|
||||
}
|
||||
else if (i == 23)
|
||||
else if (i == 22)
|
||||
{
|
||||
request.LiveStreamId = val;
|
||||
}
|
||||
else if (i == 24)
|
||||
else if (i == 23)
|
||||
{
|
||||
// Duplicating ItemId because of MediaMonkey
|
||||
}
|
||||
|
@ -1662,7 +1668,6 @@ namespace MediaBrowser.Api.Playback
|
|||
state.InputContainer = mediaSource.Container;
|
||||
state.InputFileSize = mediaSource.Size;
|
||||
state.InputBitrate = mediaSource.Bitrate;
|
||||
state.ReadInputAtNativeFramerate = mediaSource.ReadAtNativeFramerate;
|
||||
state.RunTimeTicks = mediaSource.RunTimeTicks;
|
||||
state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ namespace MediaBrowser.Api.Playback.Dash
|
|||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg;
|
||||
|
||||
// Add resolution params, if specified
|
||||
if (!hasGraphicalSubs)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Dlna;
|
||||
|
@ -475,41 +474,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// if a different file is encoding, it's done
|
||||
//var currentTranscodingIndex = GetCurrentTranscodingIndex(playlistPath);
|
||||
//if (currentTranscodingIndex > segmentIndex)
|
||||
//{
|
||||
//return GetSegmentResult(segmentPath, segmentIndex);
|
||||
//}
|
||||
|
||||
//// Wait for the file to stop being written to, then stream it
|
||||
//var length = new FileInfo(segmentPath).Length;
|
||||
//var eofCount = 0;
|
||||
|
||||
//while (eofCount < 10)
|
||||
//{
|
||||
// var info = new FileInfo(segmentPath);
|
||||
|
||||
// if (!info.Exists)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// var newLength = info.Length;
|
||||
|
||||
// if (newLength == length)
|
||||
// {
|
||||
// eofCount++;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// eofCount = 0;
|
||||
// }
|
||||
|
||||
// length = newLength;
|
||||
// await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||
//}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return GetSegmentResult(state, segmentPath, segmentIndex, transcodingJob);
|
||||
}
|
||||
|
@ -871,7 +835,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg;
|
||||
|
||||
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args += " " + GetVideoQualityParam(state, GetH264Encoder(state), true) + keyFrameArg;
|
||||
|
||||
// Add resolution params, if specified
|
||||
if (!hasGraphicalSubs)
|
||||
|
|
|
@ -70,7 +70,6 @@ namespace MediaBrowser.Api.Playback
|
|||
public string DeviceProfileId { get; set; }
|
||||
|
||||
public string Params { get; set; }
|
||||
public string ClientTime { get; set; }
|
||||
public string PlaySessionId { get; set; }
|
||||
public string LiveStreamId { get; set; }
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
var options = GetOptions();
|
||||
|
||||
if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdInSeconds))
|
||||
if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleThresholdSeconds))
|
||||
{
|
||||
PauseTranscoding();
|
||||
}
|
||||
|
|
|
@ -79,20 +79,6 @@ namespace MediaBrowser.LocalMetadata.Savers
|
|||
builder.Append("<GameSystem>" + SecurityElement.Escape(game.GameSystem) + "</GameSystem>");
|
||||
}
|
||||
|
||||
var val = game.GetProviderId(MetadataProviders.NesBox);
|
||||
|
||||
if (!string.IsNullOrEmpty(val))
|
||||
{
|
||||
builder.Append("<NesBox>" + SecurityElement.Escape(val) + "</NesBox>");
|
||||
}
|
||||
|
||||
val = game.GetProviderId(MetadataProviders.NesBoxRom);
|
||||
|
||||
if (!string.IsNullOrEmpty(val))
|
||||
{
|
||||
builder.Append("<NesBoxRom>" + SecurityElement.Escape(val) + "</NesBoxRom>");
|
||||
}
|
||||
|
||||
XmlSaverHelpers.AddCommonNodes(game, _libraryManager, builder);
|
||||
|
||||
builder.Append("</Item>");
|
||||
|
|
|
@ -359,7 +359,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
/// <returns>System.String.</returns>
|
||||
protected string GetVideoDecoder(EncodingJob state)
|
||||
{
|
||||
if (string.Equals(GetEncodingOptions().HardwareVideoDecoder, "qsv", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec))
|
||||
{
|
||||
|
|
|
@ -8,14 +8,14 @@ namespace MediaBrowser.Model.Configuration
|
|||
public double DownMixAudioBoost { get; set; }
|
||||
public bool EnableDebugLogging { get; set; }
|
||||
public bool EnableThrottling { get; set; }
|
||||
public int ThrottleThresholdInSeconds { get; set; }
|
||||
public string HardwareVideoDecoder { get; set; }
|
||||
public int ThrottleThresholdSeconds { get; set; }
|
||||
public string HardwareAccelerationType { get; set; }
|
||||
|
||||
public EncodingOptions()
|
||||
{
|
||||
DownMixAudioBoost = 2;
|
||||
EnableThrottling = true;
|
||||
ThrottleThresholdInSeconds = 120;
|
||||
ThrottleThresholdSeconds = 110;
|
||||
EncodingThreadCount = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
int? width = null;
|
||||
int? height = null;
|
||||
bool isInterlaced = true;
|
||||
var videoCodec = !string.IsNullOrWhiteSpace(GetEncodingOptions().HardwareVideoDecoder) ? null : "mpeg2video";
|
||||
var videoCodec = !string.IsNullOrWhiteSpace(GetEncodingOptions().HardwareAccelerationType) ? null : "mpeg2video";
|
||||
|
||||
int? videoBitrate = null;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user