Search code examples
c#.net.net-coreffmpeg

C# Medallion.Shell Filter output in console


I try to filter the output in console with the Medallion.Shell

                var command = Command.Run(
                    ffMpegBinaryPath,
                    args);
                command.RedirectTo(Console.OpenStandardOutput());
                command.RedirectFrom(Console.OpenStandardInput());
                command.RedirectStandardErrorTo(Console.OpenStandardError());

In this way i can't filter the output...

before I used the ProcessInfo directly, is there a way to get the same result with that library Medallion?

                using var FFmpegProcess = Process.Start(procStartInfo) ?? throw new InvalidOperationException("null process");
                FFmpegProcess.ErrorDataReceived += delegate (object sender, DataReceivedEventArgs received)
                {
                    if (received?.Data is not null &&
                        received.Data.StartsWith("frame=", StringComparison.InvariantCulture))
                    {
                        Console.WriteLine(received.Data);
                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                    }
                };

Solution

  • var command = Command.Run("python", "./patool", "--verbose",
                    "--non-interactive", "extract", filePath, "--outdir", folderPath);
                
    foreach (var line in command.GetOutputAndErrorLines())
    {
        Console.WriteLine(line);
    }