Apply suggestions from code review

Co-authored-by: Cody Robibero <cody@robibe.ro>
Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
Co-authored-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
nyanmisaka 2021-12-24 16:50:40 +08:00
parent 4b9c84c52e
commit b2d85a02c2
7 changed files with 572 additions and 588 deletions

File diff suppressed because it is too large Load Diff

View File

@ -110,23 +110,7 @@ namespace MediaBrowser.Controller.MediaEncoding
public string OutputContainer { get; set; }
public string OutputVideoSync
{
get
{
// For live tv + in progress recordings
if (string.Equals(InputContainer, "mpegts", StringComparison.OrdinalIgnoreCase)
|| string.Equals(InputContainer, "ts", StringComparison.OrdinalIgnoreCase))
{
if (!MediaSource.RunTimeTicks.HasValue)
{
return "cfr";
}
}
return "-1";
}
}
public string OutputVideoSync { get; set; }
public string AlbumCoverPath { get; set; }

View File

@ -25,6 +25,30 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <value>The encoder path.</value>
string EncoderPath { get; }
/// <summary>
/// Gets the version of encoder.
/// </summary>
/// <returns>The version of encoder.</returns>
Version EncoderVersion { get; }
/// <summary>
/// Whether the configured Vaapi device is from AMD(radeonsi/r600 Mesa driver).
/// </summary>
/// <value><c>true</c> if the Vaapi device is an AMD(radeonsi/r600 Mesa driver) GPU, <c>false</c> otherwise.</value>
bool IsVaapiDeviceAmd { get; }
/// <summary>
/// Whether the configured Vaapi device is from Intel(iHD driver).
/// </summary>
/// <value><c>true</c> if the Vaapi device is an Intel(iHD driver) GPU, <c>false</c> otherwise.</value>
bool IsVaapiDeviceInteliHD { get; }
/// <summary>
/// Whether the configured Vaapi device is from Intel(legacy i965 driver).
/// </summary>
/// <value><c>true</c> if the Vaapi device is an Intel(legacy i965 driver) GPU, <c>false</c> otherwise.</value>
bool IsVaapiDeviceInteli965 { get; }
/// <summary>
/// Whether given encoder codec is supported.
/// </summary>
@ -60,30 +84,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <returns><c>true</c> if the filter is supported, <c>false</c> otherwise.</returns>
bool SupportsFilterWithOption(FilterOptionType option);
/// <summary>
/// Whether the configured Vaapi device is from AMD(radeonsi/r600 Mesa driver).
/// </summary>
/// <returns><c>true</c> if the Vaapi device is an AMD(radeonsi/r600 Mesa driver) GPU, <c>false</c> otherwise.</returns>
bool IsVaapiDeviceAmd();
/// <summary>
/// Whether the configured Vaapi device is from Intel(iHD driver).
/// </summary>
/// <returns><c>true</c> if the Vaapi device is an Intel(iHD driver) GPU, <c>false</c> otherwise.</returns>
bool IsVaapiDeviceInteliHD();
/// <summary>
/// Whether the configured Vaapi device is from Intel(legacy i965 driver).
/// </summary>
/// <returns><c>true</c> if the Vaapi device is an Intel(legacy i965 driver) GPU, <c>false</c> otherwise.</returns>
bool IsVaapiDeviceInteli965();
/// <summary>
/// Get the version of media encoder.
/// </summary>
/// <returns>The version of media encoder.</returns>
Version GetMediaEncoderVersion();
/// <summary>
/// Extracts the audio image.
/// </summary>

View File

@ -351,18 +351,16 @@ namespace MediaBrowser.MediaEncoding.Encoder
return false;
}
string output;
try
{
output = GetProcessOutput(_encoderPath, "-v verbose -hide_banner -init_hw_device vaapi=va:" + renderNodePath, true);
var output = GetProcessOutput(_encoderPath, "-v verbose -hide_banner -init_hw_device vaapi=va:" + renderNodePath, true);
return output.Contains(driverName, StringComparison.Ordinal);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error detecting the given vaapi render node path");
return false;
}
return output.Contains(driverName, StringComparison.Ordinal);
}
private IEnumerable<string> GetHwaccelTypes()

View File

@ -91,6 +91,10 @@ namespace MediaBrowser.MediaEncoding.Encoder
/// <inheritdoc />
public string EncoderPath => _ffmpegPath;
public Version EncoderVersion => _ffmpegVersion;
public bool IsVaapiDeviceAmd => _isVaapiDeviceAmd;
public bool IsVaapiDeviceInteliHD => _isVaapiDeviceInteliHD;
public bool IsVaapiDeviceInteli965 => _isVaapiDeviceInteli965;
/// <summary>
/// Run at startup or if the user removes a Custom path from transcode page.
@ -138,7 +142,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
SetAvailableHwaccels(validator.GetHwaccels());
SetMediaEncoderVersion(validator);
options = _configurationManager.GetEncodingOptions();
_threads = EncodingHelper.GetNumberOfThreads(null, options, null);
// Check the Vaapi device vendor
@ -329,26 +332,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
return false;
}
public bool IsVaapiDeviceAmd()
{
return _isVaapiDeviceAmd;
}
public bool IsVaapiDeviceInteliHD()
{
return _isVaapiDeviceInteliHD;
}
public bool IsVaapiDeviceInteli965()
{
return _isVaapiDeviceInteli965;
}
public Version GetMediaEncoderVersion()
{
return _ffmpegVersion;
}
public bool CanEncodeToAudioCodec(string codec)
{
if (string.Equals(codec, "opus", StringComparison.OrdinalIgnoreCase))

View File

@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Configuration
VaapiDevice = "/dev/dri/renderD128";
EnableTonemapping = false;
EnableVppTonemapping = false;
TonemappingAlgorithm = "hable";
TonemappingAlgorithm = "bt2390";
TonemappingRange = "auto";
TonemappingDesat = 0;
TonemappingThreshold = 0.8;