Merge branch 'master' into feature/ffmpeg-version-check

This commit is contained in:
Max Git
2020-06-17 02:52:38 +02:00
448 changed files with 2976 additions and 906 deletions

View File

@@ -14,23 +14,45 @@ namespace MediaBrowser.MediaEncoding.Encoder
private static readonly string[] _requiredDecoders = new[]
{
"h264",
"hevc",
"mpeg2video",
"h264_qsv",
"hevc_qsv",
"mpeg2_qsv",
"mpeg2_mmal",
"mpeg4_mmal",
"vc1_qsv",
"vc1_mmal",
"h264_cuvid",
"hevc_cuvid",
"mpeg4",
"msmpeg4",
"dts",
"ac3",
"aac",
"mp3",
"h264",
"h264_qsv",
"hevc_qsv",
"mpeg2_qsv",
"vc1_qsv",
"vp8_qsv",
"vp9_qsv",
"h264_cuvid",
"hevc_cuvid",
"mpeg2_cuvid",
"vc1_cuvid",
"mpeg4_cuvid",
"vp8_cuvid",
"vp9_cuvid",
"h264_mmal",
"hevc"
"mpeg2_mmal",
"mpeg4_mmal",
"vc1_mmal",
"h264_mediacodec",
"hevc_mediacodec",
"mpeg2_mediacodec",
"mpeg4_mediacodec",
"vp8_mediacodec",
"vp9_mediacodec",
"h264_opencl",
"hevc_opencl",
"mpeg2_opencl",
"mpeg4_opencl",
"vp8_opencl",
"vp9_opencl",
"vc1_opencl"
};
private static readonly string[] _requiredEncoders = new[]
@@ -43,22 +65,24 @@ namespace MediaBrowser.MediaEncoding.Encoder
"libvpx-vp9",
"aac",
"libfdk_aac",
"ac3",
"libmp3lame",
"libopus",
"libvorbis",
"srt",
"h264_nvenc",
"hevc_nvenc",
"h264_amf",
"hevc_amf",
"h264_qsv",
"hevc_qsv",
"h264_omx",
"hevc_omx",
"h264_nvenc",
"hevc_nvenc",
"h264_vaapi",
"hevc_vaapi",
"h264_omx",
"hevc_omx",
"h264_v4l2m2m",
"ac3",
"h264_amf",
"hevc_amf"
"h264_videotoolbox",
"hevc_videotoolbox"
};
// These are the library versions that corresponds to our minimum ffmpeg version 4.x according to the version table below
@@ -175,6 +199,8 @@ namespace MediaBrowser.MediaEncoding.Encoder
public IEnumerable<string> GetEncoders() => GetCodecs(Codec.Encoder);
public IEnumerable<string> GetHwaccels() => GetHwaccelTypes();
/// <summary>
/// Using the output from "ffmpeg -version" work out the FFmpeg version.
/// For pre-built binaries the first line should contain a string like "ffmpeg version x.y", which is easy
@@ -284,6 +310,29 @@ namespace MediaBrowser.MediaEncoding.Encoder
Decoder
}
private IEnumerable<string> GetHwaccelTypes()
{
string output = null;
try
{
output = GetProcessOutput(_encoderPath, "-hwaccels");
}
catch (Exception ex)
{
_logger.LogError(ex, "Error detecting available hwaccel types");
}
if (string.IsNullOrWhiteSpace(output))
{
return Enumerable.Empty<string>();
}
var found = output.Split(new char[] {'\r','\n'}, StringSplitOptions.RemoveEmptyEntries).Skip(1).Distinct().ToList();
_logger.LogInformation("Available hwaccel types: {Types}", found);
return found;
}
private IEnumerable<string> GetCodecs(Codec codec)
{
string codecstr = codec == Codec.Encoder ? "encoders" : "decoders";

View File

@@ -25,7 +25,7 @@ using System.Diagnostics;
namespace MediaBrowser.MediaEncoding.Encoder
{
/// <summary>
/// Class MediaEncoder
/// Class MediaEncoder.
/// </summary>
public class MediaEncoder : IMediaEncoder, IDisposable
{
@@ -111,6 +111,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
SetAvailableDecoders(validator.GetDecoders());
SetAvailableEncoders(validator.GetEncoders());
SetAvailableHwaccels(validator.GetHwaccels());
}
_logger.LogInformation("FFmpeg: {EncoderLocation}: {FfmpegPath}", EncoderLocation, _ffmpegPath ?? string.Empty);
@@ -225,6 +226,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
return inJellyfinPath;
}
var values = Environment.GetEnvironmentVariable("PATH");
foreach (var path in values.Split(Path.PathSeparator))
@@ -254,6 +256,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
// _logger.Info("Supported decoders: {0}", string.Join(",", list.ToArray()));
}
private List<string> _hwaccels = new List<string>();
public void SetAvailableHwaccels(IEnumerable<string> list)
{
_hwaccels = list.ToList();
//_logger.Info("Supported hwaccels: {0}", string.Join(",", list.ToArray()));
}
public bool SupportsEncoder(string encoder)
{
return _encoders.Contains(encoder, StringComparer.OrdinalIgnoreCase);
@@ -264,6 +273,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
return _decoders.Contains(decoder, StringComparer.OrdinalIgnoreCase);
}
public bool SupportsHwaccel(string hwaccel)
{
return _hwaccels.Contains(hwaccel, StringComparer.OrdinalIgnoreCase);
}
public bool CanEncodeToAudioCodec(string codec)
{
if (string.Equals(codec, "opus", StringComparison.OrdinalIgnoreCase))
@@ -422,7 +436,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
/// <summary>
/// The us culture
/// The us culture.
/// </summary>
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");