From d6f0a9ba55832503455e2c3740199e13d60308b5 Mon Sep 17 00:00:00 2001 From: Zen <46526140+master-of-zen@users.noreply.github.com> Date: Thu, 13 Feb 2020 00:56:08 +0200 Subject: [PATCH] + improvements from #27 --- av1an.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/av1an.py b/av1an.py index 3fb82fa..09423b4 100755 --- a/av1an.py +++ b/av1an.py @@ -139,7 +139,6 @@ class Av1an: cpu = os.cpu_count() ram = round(virtual_memory().total / 2 ** 30) - if self.args.workers != 0: self.workers = self.args.workers elif self.encoder == 'aom' or 'rav1e': @@ -438,15 +437,19 @@ class Av1an: print('Wrong encoding settings') sys.exit() - # Determine resources - self.determine_resources() + # Determine resources if workers don't set + if self.args.workers != 0: + self.workers = self.args.workers + else: + self.determine_resources() - # Creating threading pool to encode bunch of files at the same time - print(f'\rWorkers: {self.workers} Params: {self.encoding_params}') - - # Progress bar + # Creating threading pool to encode bunch of files at the same time and show progress bar with Pool(self.workers) as pool: + self.workers = min(len(commands), self.workers) + + print(f'\rWorkers: {self.workers} Params: {self.encoding_params}') + for i, _ in enumerate(tqdm(pool.imap_unordered(self.encode, commands), total=len(files), leave=True), 1): pass