5

I need to stream the standard output from ffmpeg.exe directly to a web response stream on the fly. I have no problem setting up the command line with Process/RedirectStandardOutput/etc to pipe the output stream.

However, the problem seems to be the output from Process.StandardOutput is not in the correct raw format. Something like this (pseudocode):

var ffpsi = new ProcessStartInfo("ffmpeg.exe", "-i input.mp3 -acodec copy -f mp3 -")
ffpsi.UseShellExecute = false;
ffpsi.RedirectStandardOutput = true;
var ffmpegProcess = new Process();
ffpmpegProcess.StartInfo = ffpsi;

ffmpegProcess.Start();

var outputFile = new FileStream("out.mp3");
ffmpegProcess.StandardOutput.BaseStream.CopyTo(outputFile);

creates a file a little larger than the original and it's clearly not a valid MP3.

I've played with various encodings copying strategies with the base streams and get data from the async callbacks, but nothing seems to work.

Any ideas here? I guess this comes down to how to get the raw binary output from ffmpeg stdout into a .NET stream I can pass to a response stream?

Gent
  • 121
  • 4
  • Possibly related (reading binary data from a `Process`): http://stackoverflow.com/questions/4143281/capturing-binary-output-from-process-standardoutput – Patrick Quirk Nov 11 '12 at 17:31

0 Answers0