tags:

views:

100

answers:

1

I'm making a nice little Python GUI frontend for ffmpeg on Windows (one that is specifically designed to convert videos to an iPhone-friendly format and automatically import it to iTunes and tag it), and I want it to work so that you can pause the process and resume it if you want.

Since I start ffmpeg as a separate process, the obvious solution would be for the program to suspend the process (which I know is possible in Windows, Process Explorer can do it), but I can't figure out how to do it. Does anyone have any idea how to do this in Python?

+2  A: 

There is a question already on StackOverflow on how to do this in C#. I'm afraid I don't know what you need to do to directly call these APIs in Python, but I imagine it is very similar, especially if you're working in IronPython.

Edit: Unfortunately, further reading on StackOverflow also heavily cautions away from using this API. Quoting the MSDN documentation on SuspendThread:

This function is primarily designed for use by debuggers. It is not intended to be used for thread synchronization. Calling SuspendThread on a thread that owns a synchronization object, such as a mutex or critical section, can lead to a deadlock if the calling thread tries to obtain a synchronization object owned by a suspended thread. To avoid this situation, a thread within an application that is not a debugger should signal the other thread to suspend itself. The target thread must be designed to watch for this signal and respond appropriately.

It seems the preferred method is some form of cooperative multi-tasking, but my searches for this sort of feature in ffmpeg have not resulted in any promising results. SuspendThread() may be your best option at present, unless you add hooks into ffmpeg itself to support suspend requests.

Conspicuous Compiler