C#C
C#3y ago
Sh1be

❔ ffmpeg pipes

Hello, I've been trying to get ffmpeg to work in my c# project for a few hours now.

        private async void ExtractAudio(Stream input, Stream output)
        {
            var process = new Process
            {
                StartInfo =
                {
                    FileName = "ffmpeg",
                    Arguments = "-i pipe:0 -f mp3 -codec:a libmp3lame -",
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    CreateNoWindow = false,
                }
            };

            process.Start();

            var stdin = process.StandardInput.BaseStream;
            input.CopyToAsync(stdin);
            process.StandardOutput.BaseStream.CopyToAsync(output);

            process.WaitForExit();
        }


I tried multiple different variations but none seem to work. I basically have a file in-memory and want to pass it to ffmpeg to extract the audio and then give it back to me in-memory. Everytime it runs it seemingly just gets stuck up and doesn't continue at all. Why could that be?
image.png
Was this page helpful?