Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
11th June 2021, 08:34 | #1 | Link |
Registered User
Join Date: Aug 2020
Posts: 3
|
Only a simgle instance of ffmpeg
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. Last edited by Transferred; 11th June 2021 at 10:50. |
11th June 2021, 11:21 | #3 | Link |
Software Developer
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
|
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"? 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 tool to monitor file changes
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊ Last edited by LoRd_MuldeR; 11th June 2021 at 19:00. Reason: Updated URL |
11th June 2021, 18:54 | #4 | Link |
Registered User
Join Date: Aug 2020
Posts: 3
|
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. |
Tags |
ffmpeg |
|
|