Files
ffmpeg_collection/bulk_covert_drop_audio_only.py
Elghinnarisa c326143eb8 just updates
2023-03-26 18:32:35 +02:00

44 lines
1.2 KiB
Python

import subprocess
import sys
from pathlib import Path
import os
import re
output_folder_name = "/bulk_convert_out/"
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
originalfiles = sys.orig_argv[2:]
#long path shenanigans
joined = (' '.join(originalfiles))
re.sub (' +', ' ', joined)
listed = re.split(r'(.+?mkv)', joined)
listed = list(filter(None, listed))
listed = [i.lstrip() for i in listed]
print(droppedName)
#get path of script location and remove the tail
head_tail = os.path.split(sys.argv[0])
output_path = head_tail[0]
del sys.argv[0]
#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)
for file in listed:
basename = os.path.basename(file)
print(file)
# opus audio - might not work for surround -
args = 'ffmpeg.exe -i "{file}" -map 0:v -c:v copy -map 0:a -c:a libopus -b:a 192k -map 0:s -c:s copy -f matroska "{output_path}{output_folder_name}{basename}"'.format(file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename)
#arg_list = "".join(map(str, arguments))
print(args)
#print(each)
subprocess.run(args)
k=input("press close to exit")