Skip to content

Commit

Permalink
multiple modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-wz committed Aug 13, 2022
1 parent 249d489 commit 0d225e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
12 changes: 9 additions & 3 deletions VideoExtract.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import os, subprocess, threading
from utils.get_dir import get_dir
from utils.all_video_files import valid_files
from utils.get_args import get_args

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()

def job(full_path, thread_num):
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', '-c:v', 'copy', '-an',
'-v', '0', *arguments,
f'{output_path}\{thread_num+1}.mp4'])

os.system(f"echo Thread{thread_num} finished")
Expand All @@ -19,6 +25,6 @@ def job(full_path, thread_num):
output_path = get_dir()

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

print('Job finished, exit')
19 changes: 19 additions & 0 deletions utils/get_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from distutils.log import error

list_of_args = [['-c:v', 'copy', '-an'],
['-c', 'copy'],
['-vn', '-c:a', 'copy']]
def get_args():
choice = input('Choose action:\n\
1. Video stream only\n\
2. Video and audio\n\
3. Audio only\n\
Your selection: ')
try:
choice = int(choice)
if choice > len(list_of_args): raise error # Not in the list of args
except:
print('Invalid selection, exiting now')
quit()
return list_of_args[choice-1]

0 comments on commit 0d225e1

Please sign in to comment.