-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
limit thread count to improve performance
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os, subprocess, threading, time | ||
|
||
def _job(file_path, file_name, arguments, output_path): | ||
os.system(f"echo {file_name} started") | ||
|
||
subprocess.run(['ffmpeg','-i', os.path.join(file_path, file_name), | ||
'-v', '0', *arguments, | ||
f'{output_path}\{file_name}.mp4']) | ||
|
||
os.system(f"echo {file_name} finished") | ||
|
||
def make_job(files_list, file_path, arguments, output_path): | ||
job_list = [] | ||
for file_name in files_list: | ||
job_list.append(threading.Thread(target=_job, args=(file_path, file_name, arguments, output_path))) | ||
return job_list | ||
|
||
def do_job(job_list): | ||
for job in job_list: | ||
while threading.active_count() > 4: pass | ||
else: | ||
job.start() | ||
pass |