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 (ie ctrl+c/break)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.