just changing stuff
This commit is contained in:
89
core_count_test_2.py
Normal file
89
core_count_test_2.py
Normal file
@@ -0,0 +1,89 @@
|
||||
from multiprocessing.connection import wait
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import os
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
import threading
|
||||
|
||||
output_folder_name ="/bulk_convert_out/"
|
||||
|
||||
#droppedFile = sys.argv[1]
|
||||
#droppedName = Path(droppedFile).name
|
||||
|
||||
skipto = ""
|
||||
duration = ""
|
||||
|
||||
#print(droppedName)
|
||||
droppedFile= ['test.mkv0out.mkv', "test.mkv1out.mkv","test.mkv2out.mkv","test.mkv3out.mkv","test.mkv4out.mkv","test.mkv5out.mkv"]
|
||||
#get path of script location and remove the tail
|
||||
head_tail = os.path.split(sys.argv[0])
|
||||
output_path = head_tail[0]
|
||||
|
||||
|
||||
#skip first part of sys.argv since it points to script location
|
||||
#arguments = sys.argv[1:]
|
||||
arguments = droppedFile
|
||||
|
||||
#check if output folder exists, otherwise create it
|
||||
isExist = os.path.exists(output_path+output_folder_name)
|
||||
if not isExist:
|
||||
os.makedirs(output_path+output_folder_name)
|
||||
x=3
|
||||
i=0
|
||||
org_count = len(arguments)
|
||||
|
||||
|
||||
class CustomThread(Thread):
|
||||
# constructor
|
||||
def __init__(self):
|
||||
|
||||
# execute the base constructor
|
||||
Thread.__init__(self)
|
||||
# set a default value
|
||||
self.ret = None
|
||||
|
||||
def run(self):
|
||||
#sleep(1)
|
||||
global i
|
||||
file=arguments.pop(0)
|
||||
basename = os.path.basename(file)
|
||||
print(file)
|
||||
args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v libx265 -preset veryfast -crf 22 -map 0:a -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
|
||||
print(args)
|
||||
results = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
streeamdata = results.communicate()[0]
|
||||
if results.returncode == 0:
|
||||
self.ret = 0
|
||||
print(self.ret)
|
||||
i=i-1
|
||||
|
||||
|
||||
|
||||
while arguments != False:
|
||||
if i < x:
|
||||
global self
|
||||
|
||||
#streamdata= results.communicate()[0]
|
||||
if bool(arguments) != False:
|
||||
t1 = CustomThread()
|
||||
t1.start()
|
||||
if bool(arguments) == False:
|
||||
t1.join()
|
||||
print("Completed Successfully")
|
||||
exit()
|
||||
|
||||
print("incrementing i in loop")
|
||||
i=i+1
|
||||
|
||||
else:
|
||||
current_threads = threading.active_count()-1
|
||||
current_left = len(arguments)
|
||||
current_count = current_threads-current_left
|
||||
print("Finished ",current_count,"out of ", org_count)
|
||||
f = open("log.txt", "a")
|
||||
f.write("entering false \n")
|
||||
f.close()
|
||||
sleep(1)
|
||||
print("continuing")
|
||||
Reference in New Issue
Block a user