Exemple #1
0
        private static Instance PrepareInstance(string filePath, int outputCapacity, FFOptions ffOptions)
        {
            FFProbeHelper.RootExceptionCheck();
            FFProbeHelper.VerifyFFProbeExists(ffOptions);
            var arguments = $"-loglevel error -print_format json -show_format -sexagesimal -show_streams \"{filePath}\"";
            var startInfo = new ProcessStartInfo(GlobalFFOptions.GetFFProbeBinaryPath(), arguments)
            {
                StandardOutputEncoding = ffOptions.Encoding,
                StandardErrorEncoding  = ffOptions.Encoding
            };
            var instance = new Instance(startInfo)
            {
                DataBufferCapacity = outputCapacity
            };

            return(instance);
        }
        private static string GetFFBinaryPath(string name, FFOptions ffOptions)
        {
            var ffName = name.ToLowerInvariant();

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                ffName += ".exe";
            }

            var target = Environment.Is64BitProcess ? "x64" : "x86";

            if (Directory.Exists(Path.Combine(ffOptions.BinaryFolder, target)))
            {
                ffName = Path.Combine(target, ffName);
            }

            return(Path.Combine(ffOptions.BinaryFolder, ffName));
        }
        private Instance PrepareInstance(FFOptions ffMpegOptions,
                                         out CancellationTokenSource cancellationTokenSource)
        {
            FFMpegHelper.RootExceptionCheck();
            FFMpegHelper.VerifyFFMpegExists(ffMpegOptions);
            var startInfo = new ProcessStartInfo
            {
                FileName  = GlobalFFOptions.GetFFMpegBinaryPath(ffMpegOptions),
                Arguments = _ffMpegArguments.Text,
                StandardOutputEncoding = ffMpegOptions.Encoding,
                StandardErrorEncoding  = ffMpegOptions.Encoding,
            };
            var instance = new Instance(startInfo);

            cancellationTokenSource = new CancellationTokenSource();

            if (_onOutput != null || _onTimeProgress != null || (_onPercentageProgress != null && _totalTimespan != null))
            {
                instance.DataReceived += OutputData;
            }

            return(instance);
        }
 public static void Configure(FFOptions ffOptions)
 {
     Current = ffOptions ?? throw new ArgumentNullException(nameof(ffOptions));
 }