问题
right now I have a Directshow.net graph that takes in a video file and encodes it to a file, however it just continues to run
int x = program.Run()
in DirectShow.net and i want the program to close when the full conversion is done instead of me having to guess.
how can i tell if its done encoding programatically?
回答1:
If you have a mediaEvent variable you can check against the WaitForCompletion function to see if the code is done running. if the result of the waitforcompletion ( gh in this case) is not 0, it is running, if it is equal to 0, then its done.
const int E_Abort = unchecked((int)0x80004004);
EventCode evCode;
int gh = mediaEvent.WaitForCompletion(1000, out evCode);
DsROTEntry rot = new DsROTEntry(filter);
while (gh == E_Abort)
{ System.Windows.Forms.Application.DoEvents();
gh = this.mediaEvent.WaitForCompletion(1000, out evCode); }
来源:https://stackoverflow.com/questions/6312084/how-can-i-tell-when-a-directshow-net-conversion-is-done