我正在尝试将进程的输出流写入文件。文件已创建,但是那里没有内容(0 kb)。
var ffmpeg = System.Web.HttpContext.Current.Server.MapPath("~/FFMpeg/ffmpeg.exe");
var outputDir = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/converted.mp4");
var inputArgs = "-i http://file-examples.com/wp-content/uploads/2018/04/file_example_AVI_1280_1_5MG.avi";
var outputArgs = "-c:v libx264 -preset ultrafast -crf 26 -ac 2 -c:a aac -strict -2 -b:a 128k -f mp4 -";
var process = new Process
{
StartInfo =
{
FileName = ffmpeg,
Arguments = $"{inputArgs} {outputArgs}",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
}
};
process.Start();
System.IO.Stream outputStream = process.StandardOutput.BaseStream;
process.WaitForExit();
if (process.HasExited)
{
using (var fileStream = System.IO.File.Create(outputDir))
{
outputStream.CopyTo(fileStream);
}
}