Reputation: 14155
I'm stream and successfully output converted video into mkv file.
var stream = ..incoming stream of type MemoryStream();
var process = new System.Diagnostics.Process();
process.StartInfo.Arguments = "-f mp4 -i pipe:0 -c:v libx264 -crf 20 -s 600:400 -f matroska myfile.mkv";
process.Start();
process.StandardInput.BaseStream.Write(stream.ToArray())
process.BeginOutputReadLine()
process.StandardInput.BaseStream.Close();
process.WaitForExit(1000);
My question is: how can I change the implementation (command and StandardOutput.BaseStream
in order to export results into memory stream and not file (like it's in the above example).
Upvotes: 0
Views: 748
Reputation: 5493
What you were doing in the just deleted question was correct,
-f mp4 -i pipe:0 -c:v libx264 -crf 20 -s 600:400 -f matroska pipe:1
let you write the output to a pipe. But you'll likely experience a deadlock because FFmpeg would not read the entire content of stream.ToArray()
at once. It only reads what it needs to produce the next output data frame.
So, you need to run at least 2 threads on your program, one to write to FFmpeg and another to read from FFmpeg. Unfortunately, I'm not familiar with .net so I cannot help you with actual how to, but hopefully this answer points you a right direction.
Upvotes: 1