Log in

View Full Version : Only a simgle instance of ffmpeg


Transferred
11th June 2021, 08:34
Dear Doom9ers,
Is possible to force only a single instance of ffmpeg to run on windows 10?

I have a *.bat, (with a For command), which checks a folder every several minutes and if it finds a new file encodes it. But if this has not finished and a new file appears, start a new instance of ffmpeg.
I need it to wait until it encodes all the files.

Thanks for your help.

wonkey_monkey
11th June 2021, 10:12
:script:

LoRd_MuldeR
11th June 2021, 11:21
Actually I think the "ffmpeg" invocation inside of your for loop should be "blocking" (wait for completion). In a batch file, you'd have to prefix "start ..." to the command in order to get a non-blocking invocation.

So, this batch file (alone) should never launch more than one "ffmpeg" instance at the same time. But how do you invoke the batch file "every several minutes"? :confused:

I suspect that the batch file, as a whole, gets invoked again, before the previous instance has finished. Hence you would have multiple instances of the batch file running at the same time – and thus also multiple instances of ffmpeg.

[EDIT]

Instead of invoking the batch file every N minutes, you could just keep a single instance of the batch file running "forever". For example, add goto:loop just after the end of the for loop and put label :loop just before the loop.

You may use timeout command to add some delay after each for loop, in order to not waste too much CPU time in busy waiting. Or, even better, or use my notifywait (https://sourceforge.net/projects/muldersoft/files/MSleep/MSleep.2021-06-11.zip/download) tool to monitor file changes ;)

Transferred
11th June 2021, 18:54
Thank you very much wonkey_monkey and LoRd_MuldeR,
You hit the target, I invoke the batch file with the windows task scheduler every 5 minutes.
I'll use the goto:loop and sleep to add a delay.
I will also test your notification tool to monitor.
Thank you very much, a pleasure to be a member of the forum.

Transferred
18th June 2021, 07:35
Regards, So it was solved