tomaszzmuda / Xabe.FFmpeg

.NET Standard wrapper for FFmpeg. It allows to process media without know how FFmpeg works, and can be used to pass customized arguments to FFmpeg from dotnet core application.

Home Page:https://xabe.net/product/xabe_ffmpeg/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FFProbe prints blank for this command

Adil-A-Rahman opened this issue · comments

Hello,

I am trying to run this command and find out the RMS peaks of an mp3 file. Here is the command (reference I used)
ffprobe -v error -f lavfi -i "amovie=input.mp3,astats=metadata=1:reset=1" -show_entries frame_tags=lavfi.astats.Overall.RMS_level -of csv=p=0
If I run this in the command line, I am able to get the output, but this does not work with the FFprobe code:

string result = await Probe.New().Start("-v error -f lavfi -i "amovie=input.mp3,astats=metadata=1:reset=1" -show_entries frame_tags=lavfi.astats.Overall.RMS_level -of csv=p=0");
Console.WriteLine(result);  //prints nothing

What am I doing wrong ?

If I manually call it using CMD from C#, it works. Here is the code:

string commandCMD = $"/C ffprobe -v error -f lavfi -i \"amovie=input.mp3,astats=metadata=1:reset=1\" -show_entries frame_tags=lavfi.astats.Overall.RMS_level -of csv=p=0";

string result = string.Empty;
int exitCode;
var outputs = new List<string>();

using (Process process = new())
{
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.FileName = "cmd";
    process.StartInfo.Arguments = commandCMD;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.Start();

    process.ErrorDataReceived += (sender, e) =>
    {
        if (!string.IsNullOrEmpty(e.Data))
        {
            outputs.Add(e.Data);
        }
    };
    process.BeginErrorReadLine();

    process.OutputDataReceived += (sender, e) =>
    {
        if (!string.IsNullOrEmpty(e.Data))
        {
            outputs.Add(e.Data);
        }
    };
    process.BeginOutputReadLine();

    process.WaitForExit();
    exitCode = process.ExitCode;
    process.Close();
}

foreach (var output in outputs)
{
    Console.WriteLine(output);
}

Here is the output I am expecting:
image

Thanks

Hello @Adil-A-Rahman
It turned out that this command generate some errors and output went on StandardError and is not readed.
In FFprobeWrapper.RunProcess there is a line with process.StandardError.ReadToEnd()

It needs to be changed to event listener and added StandardError listener + set standardError flag in RunProcess method to true.

I'm quite busy right now, but I really encourage to participate to creating that code :)