/// <summary> /// Validates the supplied FQPN to ensure it is a ffmpeg utility. /// If checks pass, global variable FFmpegPath and EncoderLocation are updated. /// </summary> /// <param name="path">FQPN to test.</param> /// <param name="location">Location (External, Custom, System) of tool.</param> /// <returns><c>true</c> if the version validation succeeded; otherwise, <c>false</c>.</returns> private bool ValidatePath(string path, FFmpegLocation location) { bool rc = false; if (!string.IsNullOrEmpty(path)) { if (File.Exists(path)) { rc = new EncoderValidator(_logger, path).ValidateVersion(); if (!rc) { _logger.LogWarning("FFmpeg: {Location}: Failed version check: {Path}", location, path); } _ffmpegPath = path; EncoderLocation = location; return(true); } else { _logger.LogWarning("FFmpeg: {Location}: File not found: {Path}", location, path); } } return(rc); }
/// <summary> /// Validates the supplied FQPN to ensure it is a ffmpeg utility. /// If checks pass, global variable FFmpegPath and EncoderLocation are updated. /// </summary> /// <param name="path">FQPN to test</param> /// <param name="location">Location (External, Custom, System) of tool</param> /// <returns></returns> private bool ValidatePath(string path, FFmpegLocation location) { bool rc = false; if (!string.IsNullOrEmpty(path)) { if (File.Exists(path)) { rc = new EncoderValidator(_logger, path).ValidateVersion(); if (!rc) { _logger.LogWarning("FFmpeg: {Location}: Failed version check: {Path}", location, path); } // ToDo - Enable the ffmpeg validator. At the moment any version can be used. rc = true; _ffmpegPath = path; EncoderLocation = location; } else { _logger.LogWarning("FFmpeg: {Location}: File not found: {Path}", location, path); } } return(rc); }
public bool SupportsFilter(string filter, string option) { if (_ffmpegPath != null) { var validator = new EncoderValidator(_logger, _ffmpegPath); return(validator.CheckFilter(filter, option)); } return(false); }
public void Init() { InitPaths(); if (!string.IsNullOrWhiteSpace(FFMpegPath)) { var result = new EncoderValidator(_logger, _processFactory).Validate(FFMpegPath); SetAvailableDecoders(result.decoders); SetAvailableEncoders(result.encoders); } }
public async Task Init() { InitPaths(); if (!string.IsNullOrWhiteSpace(FFMpegPath)) { var result = new EncoderValidator(_logger).Validate(FFMpegPath); SetAvailableDecoders(result.Item1); SetAvailableEncoders(result.Item2); } }
public void SetFFmpegPath() { // 1) Custom path stored in config/encoding xml file under tag <EncoderAppPath> takes precedence var ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath; if (string.IsNullOrEmpty(ffmpegPath)) { // 2) Check if the --ffmpeg CLI switch has been given ffmpegPath = _startupOptionFFmpegPath; if (string.IsNullOrEmpty(ffmpegPath)) { // 3) Check "ffmpeg" ffmpegPath = "ffmpeg"; } } if (!ValidatePath(ffmpegPath)) { _ffmpegPath = null; } // Write the FFmpeg path to the config/encoding.xml file as <EncoderAppPathDisplay> so it appears in UI var config = _configurationManager.GetEncodingOptions(); config.EncoderAppPathDisplay = _ffmpegPath ?? string.Empty; _configurationManager.SaveConfiguration("encoding", config); // Only if mpeg path is set, try and set path to probe if (_ffmpegPath != null) { // Determine a probe path from the mpeg path _ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); // Interrogate to understand what coders are supported var validator = new EncoderValidator(_logger, _ffmpegPath); SetAvailableDecoders(validator.GetDecoders()); SetAvailableEncoders(validator.GetEncoders()); SetAvailableFilters(validator.GetFilters()); SetAvailableFiltersWithOption(validator.GetFiltersWithOption()); SetAvailableHwaccels(validator.GetHwaccels()); SetMediaEncoderVersion(validator); _threads = EncodingHelper.GetNumberOfThreads(null, _configurationManager.GetEncodingOptions(), null); } _logger.LogInformation("FFmpeg: {FfmpegPath}", _ffmpegPath ?? string.Empty); }
private bool ValidatePath(string path) { if (string.IsNullOrEmpty(path)) { return(false); } bool rc = new EncoderValidator(_logger, path).ValidateVersion(); if (!rc) { _logger.LogWarning("FFmpeg: Failed version check: {Path}", path); return(false); } _ffmpegPath = path; return(true); }
/// <summary> /// Run at startup or if the user removes a Custom path from transcode page. /// Sets global variables FFmpegPath. /// Precedence is: Config > CLI > $PATH /// </summary> public void SetFFmpegPath() { // ToDo - Finalise removal of the --ffprobe switch if (!string.IsNullOrEmpty(StartupOptionFFprobePath)) { _logger.LogWarning("--ffprobe switch is deprecated and shall be removed in the next release"); } // 1) Custom path stored in config/encoding xml file under tag <EncoderAppPath> takes precedence if (!ValidatePath(ConfigurationManager.GetConfiguration <EncodingOptions>("encoding").EncoderAppPath, FFmpegLocation.Custom)) { // 2) Check if the --ffmpeg CLI switch has been given if (!ValidatePath(StartupOptionFFmpegPath, FFmpegLocation.SetByArgument)) { // 3) Search system $PATH environment variable for valid FFmpeg if (!ValidatePath(ExistsOnSystemPath("ffmpeg"), FFmpegLocation.System)) { EncoderLocation = FFmpegLocation.NotFound; FFmpegPath = null; } } } // Write the FFmpeg path to the config/encoding.xml file as <EncoderAppPathDisplay> so it appears in UI var config = ConfigurationManager.GetConfiguration <EncodingOptions>("encoding"); config.EncoderAppPathDisplay = FFmpegPath ?? string.Empty; ConfigurationManager.SaveConfiguration("encoding", config); // Only if mpeg path is set, try and set path to probe if (FFmpegPath != null) { // Determine a probe path from the mpeg path FFprobePath = Regex.Replace(FFmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); // Interrogate to understand what coders are supported var result = new EncoderValidator(_logger, _processFactory).GetAvailableCoders(FFmpegPath); SetAvailableDecoders(result.decoders); SetAvailableEncoders(result.encoders); } _logger.LogInformation("FFmpeg: {0}: {1}", EncoderLocation.ToString(), FFmpegPath ?? string.Empty); }
/// <summary> /// Run at startup or if the user removes a Custom path from transcode page. /// Sets global variables FFmpegPath. /// Precedence is: Config > CLI > $PATH. /// </summary> public void SetFFmpegPath() { // 1) Custom path stored in config/encoding xml file under tag <EncoderAppPath> takes precedence if (!ValidatePath(_configurationManager.GetEncodingOptions().EncoderAppPath, FFmpegLocation.Custom)) { // 2) Check if the --ffmpeg CLI switch has been given if (!ValidatePath(_startupOptionFFmpegPath, FFmpegLocation.SetByArgument)) { // 3) Search system $PATH environment variable for valid FFmpeg if (!ValidatePath(ExistsOnSystemPath("ffmpeg"), FFmpegLocation.System)) { EncoderLocation = FFmpegLocation.NotFound; _ffmpegPath = null; } } } // Write the FFmpeg path to the config/encoding.xml file as <EncoderAppPathDisplay> so it appears in UI var config = _configurationManager.GetEncodingOptions(); config.EncoderAppPathDisplay = _ffmpegPath ?? string.Empty; _configurationManager.SaveConfiguration("encoding", config); // Only if mpeg path is set, try and set path to probe if (_ffmpegPath != null) { // Determine a probe path from the mpeg path _ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); // Interrogate to understand what coders are supported var validator = new EncoderValidator(_logger, _ffmpegPath); SetAvailableDecoders(validator.GetDecoders()); SetAvailableEncoders(validator.GetEncoders()); SetAvailableHwaccels(validator.GetHwaccels()); threads = EncodingHelper.GetNumberOfThreads(null, _configurationManager.GetEncodingOptions(), null); } _logger.LogInformation("FFmpeg: {EncoderLocation}: {FfmpegPath}", EncoderLocation, _ffmpegPath ?? string.Empty); }
public void Init() { InitPaths(); if (!string.IsNullOrWhiteSpace(FFMpegPath)) { var result = new EncoderValidator(_logger, _processFactory).Validate(FFMpegPath); SetAvailableDecoders(result.Item1); SetAvailableEncoders(result.Item2); if (EnableEncoderFontFile) { var directory = FileSystem.GetDirectoryName(FFMpegPath); if (!string.IsNullOrWhiteSpace(directory) && FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.ProgramDataPath, directory)) { new FontConfigLoader(_httpClient, ConfigurationManager.ApplicationPaths, _logger, _zipClient, FileSystem).DownloadFonts(directory).ConfigureAwait(false); } } } }
public async Task Init() { InitPaths(); if (!string.IsNullOrWhiteSpace(FFMpegPath)) { var result = new EncoderValidator(_logger).Validate(FFMpegPath); SetAvailableDecoders(result.Item1); SetAvailableEncoders(result.Item2); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { var directory = Path.GetDirectoryName(FFMpegPath); if (!string.IsNullOrWhiteSpace(directory) && FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.ProgramDataPath, directory)) { await new FontConfigLoader(_httpClient, ConfigurationManager.ApplicationPaths, _logger, _zipClient, FileSystem).DownloadFonts(directory).ConfigureAwait(false); } } } }
public void SetMediaEncoderVersion(EncoderValidator validator) { _ffmpegVersion = validator.GetFFmpegVersion(); }
public void SetFFmpegPath() { // 1) Custom path stored in config/encoding xml file under tag <EncoderAppPath> takes precedence var ffmpegPath = _configurationManager.GetEncodingOptions().EncoderAppPath; if (string.IsNullOrEmpty(ffmpegPath)) { // 2) Check if the --ffmpeg CLI switch has been given ffmpegPath = _startupOptionFFmpegPath; if (string.IsNullOrEmpty(ffmpegPath)) { // 3) Check "ffmpeg" ffmpegPath = "ffmpeg"; } } if (!ValidatePath(ffmpegPath)) { _ffmpegPath = null; } // Write the FFmpeg path to the config/encoding.xml file as <EncoderAppPathDisplay> so it appears in UI var options = _configurationManager.GetEncodingOptions(); options.EncoderAppPathDisplay = _ffmpegPath ?? string.Empty; _configurationManager.SaveConfiguration("encoding", options); // Only if mpeg path is set, try and set path to probe if (_ffmpegPath != null) { // Determine a probe path from the mpeg path _ffprobePath = Regex.Replace(_ffmpegPath, @"[^\/\\]+?(\.[^\/\\\n.]+)?$", @"ffprobe$1"); // Interrogate to understand what coders are supported var validator = new EncoderValidator(_logger, _ffmpegPath); SetAvailableDecoders(validator.GetDecoders()); SetAvailableEncoders(validator.GetEncoders()); SetAvailableFilters(validator.GetFilters()); SetAvailableFiltersWithOption(validator.GetFiltersWithOption()); SetAvailableHwaccels(validator.GetHwaccels()); SetMediaEncoderVersion(validator); _threads = EncodingHelper.GetNumberOfThreads(null, options, null); // Check the Vaapi device vendor if (OperatingSystem.IsLinux() && SupportsHwaccel("vaapi") && !string.IsNullOrEmpty(options.VaapiDevice) && string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)) { _isVaapiDeviceAmd = validator.CheckVaapiDeviceByDriverName("Mesa Gallium driver", options.VaapiDevice); _isVaapiDeviceInteliHD = validator.CheckVaapiDeviceByDriverName("Intel iHD driver", options.VaapiDevice); _isVaapiDeviceInteli965 = validator.CheckVaapiDeviceByDriverName("Intel i965 driver", options.VaapiDevice); if (_isVaapiDeviceAmd) { _logger.LogInformation("VAAPI device {RenderNodePath} is AMD GPU", options.VaapiDevice); } else if (_isVaapiDeviceInteliHD) { _logger.LogInformation("VAAPI device {RenderNodePath} is Intel GPU (iHD)", options.VaapiDevice); } else if (_isVaapiDeviceInteli965) { _logger.LogInformation("VAAPI device {RenderNodePath} is Intel GPU (i965)", options.VaapiDevice); } } } _logger.LogInformation("FFmpeg: {FfmpegPath}", _ffmpegPath ?? string.Empty); }