This commit is contained in:
2026-02-26 15:52:01 +01:00
parent c326143eb8
commit f0faa57e98
51 changed files with 21457 additions and 22 deletions

58
screenshot_drop_subs.py Normal file
View File

@@ -0,0 +1,58 @@
import re
import subprocess
import sys
from pathlib import Path
import os
output_folder_name = "/screenshots/"
droppedFile = sys.argv[1]
droppedName = Path(droppedFile).name
#Must be run with input file in the same location as script/ffmpeg, no spaces in filename
#droppedFile = ['test_source.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:]
#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)
number_of_ss=int(input("Number of ss: "))
print(number_of_ss)
for i, file in enumerate(arguments):
arg_list = 'ffprobe.exe -show_entries format=duration -i "{file}"'.format(file=file)
print(arg_list)
cmd = subprocess.Popen(arg_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF-8')
subprocess_std = cmd.communicate()[0]
print("stdout printing: " , subprocess_std)
video_duration = [int(s) for s in re.findall(r"[0-9]+", subprocess_std)][0]
print("video_duration: ", video_duration, "s")
duration_percent = video_duration / 100
print(duration_percent)
time = duration_percent * 15
skip = ((duration_percent * 90) - (duration_percent* 15)) / (number_of_ss -1)
for i in range(0, number_of_ss):
basename = os.path.basename(file)
args = 'ffmpeg.exe -ss {time} -copyts -itsoffset -2 -i "{file}" -vf subtitles={basename} -frames:v 1 -q:v 1 "{output_path}{output_folder_name}{basename}{i}.jpeg"'.format(time=skip*i+time, file=file, output_path=output_path, output_folder_name=output_folder_name, basename=basename, i=i)
print(args)
run = subprocess.Popen(args)
print('\n')
input("press enter to exit")