Converting audio/video tracks to AAC format in C# app.

Alex1347

New member
Joined
Feb 4, 2025
Messages
2
Programming Experience
1-3
I try convert audio/video tracks to AAC format using qaac lib. In CMD it works and output information about progress of convertation. In my C# app it works too, but I can't get information about progress, i try use these events: OutputDataReceived, ErrorDataReceived. In handler of ErrorDataReceived I don't get needed information, in handler of OutputDataReceived I get received.Data like null value. How can I get conversion progress information during conversion in C# code?

(I use qaac lib because ffmpeg lib convert tracks to AAC incorrect - incorrect duration of result track, resolving not find for this problem, some analog apps have the same bug.)

Creating process for converting.:
string arguments = $"\"{engineParameters.InputFile.Filename}\" -no-delay -o \"{engineParameters.OutputFile.Filename}\"";

processStartInfo = new ProcessStartInfo
{
    FileName = QaacFilePath,
    Arguments = arguments,
    RedirectStandardOutput = true,
    UseShellExecute = false,
    CreateNoWindow = true,
    WindowStyle = ProcessWindowStyle.Hidden
};

Also i call these methods for process:
C#:
BeginOutputReadLine();
BeginErrorReadLine();
WaitForExit();

Handlers:
C#:
this.Process.OutputDataReceived += (sender, received) =>
{
    if (received.Data == null) return;
    //Some code...
}

C#:
this.Process.ErrorDataReceived += (sender, received) =>
{
    if (received.Data == null) return;
    //Some code...
}
 
Last edited:
If "qaac lib" is truly a library, why don't you just PInvoke the APIs of the library directly? I have a feeling based on a quick scan of the documentation links that "qaac" is actually a "prog" or "cli" and not a "lib".
 
Back
Top Bottom