Skip to content

Commit

Permalink
revamped job creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-wz committed Aug 13, 2022
1 parent d76d129 commit f595e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
19 changes: 4 additions & 15 deletions VideoExtract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@
from utils.get_dir import get_dir
from utils.all_video_files import valid_files
from utils.get_args import get_args
from utils.job import make_job, do_job

input('Press Enter to select a folder: ')
input_path = get_dir()
video_files = valid_files(input_path)
if len(video_files) == 0:
print('No valid video file found, exiting...')
quit()

arguments = get_args()

def job(full_path, thread_num, arguments):
os.system(f"echo Thread{thread_num} started")

subprocess.run(['ffmpeg','-i', full_path[thread_num],
'-v', '0', *arguments,
f'{output_path}\{thread_num+1}.mp4'])

os.system(f"echo Thread{thread_num} finished")

input('Press Enter to select a folder to save the results: ')
output_path = get_dir()

for thread_num in range(len(video_files)):
threading.Thread(target=job, args=(tuple(video_files),thread_num, arguments)).start()
job_list = make_job(video_files, input_path, arguments, output_path)

do_job(job_list)

print('Job finished, exit')
7 changes: 5 additions & 2 deletions utils/all_video_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ def valid_files(path):
videos = []
for item in all_items: # Sometimes extensions are in upper case
if os.path.splitext(item)[1].lower() in valid_extensions:
videos.append(os.path.join(path, item))
return videos
videos.append(item)
if len(videos) == 0:
print('No valid video file found, exiting...')
quit()
else: return videos

0 comments on commit f595e06

Please sign in to comment.