support h264_omx
This commit is contained in:
parent
4a95ec28f2
commit
52d8ddb050
|
@ -286,11 +286,19 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
protected string GetH264Encoder(StreamState state)
|
||||
{
|
||||
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
||||
return "h264_qsv";
|
||||
}
|
||||
|
||||
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "libnvenc";
|
||||
}
|
||||
if (string.Equals(ApiEntryPoint.Instance.GetEncodingOptions().HardwareAccelerationType, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "h264_omx";
|
||||
}
|
||||
|
||||
return "libx264";
|
||||
|
@ -395,15 +403,18 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
if (!string.IsNullOrEmpty(state.VideoRequest.Profile))
|
||||
{
|
||||
param += " -profile:v " + state.VideoRequest.Profile;
|
||||
if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// not supported by h264_omx
|
||||
param += " -profile:v " + state.VideoRequest.Profile;
|
||||
}
|
||||
}
|
||||
|
||||
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(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(videoCodec, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
switch (state.VideoRequest.Level)
|
||||
{
|
||||
|
@ -438,16 +449,21 @@ namespace MediaBrowser.Api.Playback
|
|||
param += " -level " + state.VideoRequest.Level;
|
||||
break;
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
else
|
||||
else if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
param += " -level " + state.VideoRequest.Level;
|
||||
}
|
||||
}
|
||||
|
||||
return "-pix_fmt yuv420p " + param;
|
||||
if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoCodec, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
param = "-pix_fmt yuv420p " + param;
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
protected string GetAudioFilterParam(StreamState state, bool isHls)
|
||||
|
@ -563,14 +579,6 @@ namespace MediaBrowser.Api.Playback
|
|||
filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(ih\\,{0})", maxHeightParam));
|
||||
}
|
||||
|
||||
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (filters.Count > 1)
|
||||
{
|
||||
//filters[filters.Count - 1] += ":flags=fast_bilinear";
|
||||
}
|
||||
}
|
||||
|
||||
var output = string.Empty;
|
||||
|
||||
if (state.SubtitleStream != null && state.SubtitleStream.IsTextSubtitleStream && state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Encode)
|
||||
|
@ -1650,7 +1658,7 @@ namespace MediaBrowser.Api.Playback
|
|||
if (!string.IsNullOrWhiteSpace(request.AudioCodec))
|
||||
{
|
||||
state.SupportedAudioCodecs = request.AudioCodec.Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
||||
state.Request.AudioCodec = state.SupportedAudioCodecs.FirstOrDefault(i => MediaEncoder.CanEncodeToAudioCodec(i))
|
||||
state.Request.AudioCodec = state.SupportedAudioCodecs.FirstOrDefault(i => MediaEncoder.CanEncodeToAudioCodec(i))
|
||||
?? state.SupportedAudioCodecs.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
|
|
@ -377,7 +377,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
if (MediaEncoder.SupportsDecoder("h264_qsv"))
|
||||
{
|
||||
// Seeing stalls and failures with decoding. Not worth it compared to encoding.
|
||||
//return "-c:v h264_qsv ";
|
||||
return "-c:v h264_qsv ";
|
||||
}
|
||||
break;
|
||||
case "mpeg2video":
|
||||
|
@ -672,17 +672,20 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
if (!string.IsNullOrEmpty(state.Options.Profile))
|
||||
{
|
||||
param += " -profile:v " + state.Options.Profile;
|
||||
if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// not supported by h264_omx
|
||||
param += " -profile:v " + state.Options.Profile;
|
||||
}
|
||||
}
|
||||
|
||||
var levelString = state.Options.Level.HasValue ? state.Options.Level.Value.ToString(CultureInfo.InvariantCulture) : null;
|
||||
|
||||
if (!string.IsNullOrEmpty(levelString))
|
||||
{
|
||||
var h264Encoder = EncodingJobFactory.GetH264Encoder(state, GetEncodingOptions());
|
||||
|
||||
// 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(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(videoCodec, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
switch (levelString)
|
||||
{
|
||||
|
@ -718,13 +721,20 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
param += " -level " + levelString;
|
||||
}
|
||||
}
|
||||
|
||||
return "-pix_fmt yuv420p " + param;
|
||||
if (!string.Equals(videoCodec, "h264_omx", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(videoCodec, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
param = "-pix_fmt yuv420p " + param;
|
||||
}
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
protected string GetVideoBitrateParam(EncodingJob state, string videoCodec)
|
||||
|
|
|
@ -27,17 +27,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
return new Tuple<List<string>, List<string>>(decoders, encoders);
|
||||
}
|
||||
|
||||
private List<string> GetDecoders(string ffmpegPath)
|
||||
private List<string> GetDecoders(string encoderAppPath)
|
||||
{
|
||||
string output = string.Empty;
|
||||
try
|
||||
{
|
||||
output = GetFFMpegOutput(ffmpegPath, "-decoders");
|
||||
output = GetProcessOutput(encoderAppPath, "-decoders");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
//_logger.Debug("ffmpeg decoder query result: {0}", output ?? string.Empty);
|
||||
|
||||
var found = new List<string>();
|
||||
var required = new[]
|
||||
|
@ -51,12 +50,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
{
|
||||
var srch = " " + codec + " ";
|
||||
|
||||
if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) == -1)
|
||||
{
|
||||
_logger.Warn("ffmpeg is missing decoder " + codec);
|
||||
}
|
||||
else
|
||||
if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
_logger.Info("Decoder available: " + codec);
|
||||
found.Add(codec);
|
||||
}
|
||||
}
|
||||
|
@ -64,17 +60,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
return found;
|
||||
}
|
||||
|
||||
private List<string> GetEncoders(string ffmpegPath)
|
||||
private List<string> GetEncoders(string encoderAppPath)
|
||||
{
|
||||
string output = null;
|
||||
try
|
||||
{
|
||||
output = GetFFMpegOutput(ffmpegPath, "-encoders");
|
||||
output = GetProcessOutput(encoderAppPath, "-encoders");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
//_logger.Debug("ffmpeg encoder query result: {0}", output ?? string.Empty);
|
||||
|
||||
var found = new List<string>();
|
||||
var required = new[]
|
||||
|
@ -89,19 +84,18 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
"libmp3lame",
|
||||
"libopus",
|
||||
//"libvorbis",
|
||||
"srt"
|
||||
"srt",
|
||||
"libnvenc",
|
||||
"h264_qsv"
|
||||
};
|
||||
|
||||
foreach (var codec in required)
|
||||
{
|
||||
var srch = " " + codec + " ";
|
||||
|
||||
if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) == -1)
|
||||
{
|
||||
_logger.Warn("ffmpeg is missing encoder " + codec);
|
||||
}
|
||||
else
|
||||
if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
_logger.Info("Encoder available: " + codec);
|
||||
found.Add(codec);
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +103,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
return found;
|
||||
}
|
||||
|
||||
private string GetFFMpegOutput(string path, string arguments)
|
||||
private string GetProcessOutput(string path, string arguments)
|
||||
{
|
||||
var process = new Process
|
||||
{
|
||||
|
@ -147,7 +141,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
_logger.ErrorException("Error killing ffmpeg", ex1);
|
||||
_logger.ErrorException("Error killing process", ex1);
|
||||
}
|
||||
|
||||
throw;
|
||||
|
|
|
@ -556,13 +556,19 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
|
||||
internal static string GetH264Encoder(EncodingJob state, EncodingOptions options)
|
||||
{
|
||||
if (string.Equals(options.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(options.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(options.HardwareAccelerationType, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// It's currently failing on live tv
|
||||
if (state.RunTimeTicks.HasValue)
|
||||
{
|
||||
return "h264_qsv";
|
||||
}
|
||||
return "h264_qsv";
|
||||
}
|
||||
|
||||
if (string.Equals(options.HardwareAccelerationType, "libnvenc", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "libnvenc";
|
||||
}
|
||||
if (string.Equals(options.HardwareAccelerationType, "h264_omx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "h264_omx";
|
||||
}
|
||||
|
||||
return "libx264";
|
||||
|
|
Loading…
Reference in New Issue
Block a user