如何使用ffmpeg和C#捕获设备? [英] How can I catch devices using ffmpeg and C#?
本文介绍了如何使用ffmpeg和C#捕获设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用ffmpeg.exe捕获设备。我使用了Process类和相关的ffmpeg命令但没有成功
我尝试过:
i使用以下代码,但输出是什么!我认为这是因为process.start()执行后进程退出。我怎么能这样做?
I want to catch devices using ffmpeg.exe. i used Process class and related ffmpeg command but no success
What I have tried:
i used following code but the output is nothing!! i think it happens because the process exited as soon as process.start() executed. how can i do that?
static void Main(string[] args)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "ffmpeg.exe";
startInfo.Arguments = "-list_devices true -f dshow -i dummy";
startInfo.RedirectStandardOutput = false;
try
{
using (Process process = Process.Start(startInfo))
{
while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
Console.WriteLine(line);
}
process.WaitForExit();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadKey();
}
}
推荐答案
你想捕获输出?这应该回答您的问题:从.NET应用程序捕获控制台输出(C#) - 堆栈溢出 [ ^ ]
You want to "capture" the output? This should answer your question: Capturing console output from a .NET application (C#) - Stack Overflow[^]
这篇关于如何使用ffmpeg和C#捕获设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文