如何停止ffmpeg的视频在c#记录? [英] How to stop ffmpeg video recording in c#?
问题描述
我使用的FFmpeg的应用程序,它开始和录制视频完美
,但是当我想阻止它要求按Q,我得到了System.EntryPointNotFoundException的错误消息。
我怎么能发送短信q来处理这是在运行从应用程序的状态
INT key_q = 81;
函数[DllImport(user32.dll中,入口点=PostMessage的)]
私人静态的extern BOOL PostMessage的(HWND的IntPtr,UINT味精,诠释WPARAM,LPARAM INT);
私人无效button_stop_Click(对象发件人,EventArgs五)
{
串过程=的ffmpeg;
过程[] =亲Process.GetProcessesByName(FFMPEG);
亲[0] .REFRESH();
IntPtr的H =亲[0] .MainWindowHandle;
PostMessage的(H,为0x100,key_q,0);
}
如果您创建的过程中开始,你可以把手保持它的标准输入并发送q(可能还需要发送一个\\\
后)。
如果你没有,那么你可以一些第三方的.exe(或内部等效)向它发送一个CTRL + C / Ctrl + Break其进程ID。
FFmpeg的没有一个窗口句柄,因为它是一个控制台应用程序,所以你不能把它与PostMessage的等按键。只有通过控制台信号(即CTRL + C /休息)
I am using FFmpeg in application and it start and record video perfectly but when I want to stop it ask for press "q", I got a System.EntryPointNotFoundException Error message.
How can I send message "q" to process which is in running state from application
int key_q = 81;
[DllImport("user32.dll", EntryPoint = "postmessage")]
private static extern bool postmessage(IntPtr hwnd, uint msg, int wparam, int lparam);
private void button_stop_Click(object sender, EventArgs e)
{
string process = "ffmpeg";
Process[] pro = Process.GetProcessesByName("ffmpeg");
pro[0].Refresh();
IntPtr h = pro[0].MainWindowHandle;
postmessage(h, 0x100, key_q, 0);
}
If you created the process initially, you can keep a handle to its stdin and send it "q" (possibly need to also send it a "\n" after).
If you didn't, then you could some third party .exe (or an internal equivalent) to send it a ctrl+c/ctrl+break to its process ID.
FFmpeg doesn't have a window handle since it's a console app, so you can't send it keystrokes with PostMessage et al. only through console signals (i.e. ctrl+c/break)
这篇关于如何停止ffmpeg的视频在c#记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!