refract
This commit is contained in:
36
prepare.py
36
prepare.py
@@ -6,6 +6,7 @@ import pathlib
|
|||||||
import moviepy.editor
|
import moviepy.editor
|
||||||
import moviepy
|
import moviepy
|
||||||
import pymediainfo
|
import pymediainfo
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
class Args:
|
class Args:
|
||||||
@@ -42,22 +43,13 @@ def info(mfile, media_info):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def screens(fold, max_time):
|
def screens(fold, mintimescr, maxtimescr, screen_create):
|
||||||
|
time = random.randint(mintimescr, maxtimescr)
|
||||||
|
imgname = fold + "/" + str(time) + ".png"
|
||||||
|
print(" time %ds" % time)
|
||||||
|
|
||||||
print("Creating %s screenschots" % Args.args.count)
|
make_screen = screen_create.save_frame(imgname, t=time)
|
||||||
i = 0
|
|
||||||
max_time = round(max_time)
|
|
||||||
print("Rounded duration %ss" % max_time)
|
|
||||||
screen_create = moviepy.editor.VideoFileClip(Args.args.input)
|
|
||||||
mintimescr = round(max_time * 0.05)
|
|
||||||
maxtimescr = round(max_time * 0.95)
|
|
||||||
|
|
||||||
while i < Args.args.count:
|
|
||||||
i += 1
|
|
||||||
time = random.randint(mintimescr, maxtimescr)
|
|
||||||
imgname = fold + "/" + str(time) + ".png"
|
|
||||||
print("%s at time %ds" % (i, time))
|
|
||||||
screen_create.save_frame(imgname, t=time)
|
|
||||||
|
|
||||||
screen_create.reader.close()
|
screen_create.reader.close()
|
||||||
screen_create.audio.reader.close_proc()
|
screen_create.audio.reader.close_proc()
|
||||||
@@ -95,10 +87,24 @@ class Head:
|
|||||||
if Args.args.sample:
|
if Args.args.sample:
|
||||||
sample(fold, exname, max_time)
|
sample(fold, exname, max_time)
|
||||||
if Args.args.screens:
|
if Args.args.screens:
|
||||||
screens(fold, max_time)
|
print("Creating %s screenschots" % Args.args.count)
|
||||||
|
i = 0
|
||||||
|
max_time = round(max_time)
|
||||||
|
print("Rounded duration %ss" % max_time)
|
||||||
|
screen_create = moviepy.editor.VideoFileClip(Args.args.input)
|
||||||
|
mintimescr = round(max_time * 0.05)
|
||||||
|
maxtimescr = round(max_time * 0.95)
|
||||||
|
|
||||||
|
return mintimescr, maxtimescr, fold, screen_create
|
||||||
|
# screens(fold, mintimescr, maxtimescr, screen_create)
|
||||||
if Args.args.mediainfo:
|
if Args.args.mediainfo:
|
||||||
info(mfile, media_info)
|
info(mfile, media_info)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Head()
|
Head()
|
||||||
|
if Args.args.screens:
|
||||||
|
for i in range (Args.args.count):
|
||||||
|
condition = threading.Condition()
|
||||||
|
thread = threading.Thread(name="screenshot", target=screens, args=(Head.mintimescr, Head.maxtimescr, Head.fold, Head.screen_create))
|
||||||
|
thread.start()
|
||||||
Reference in New Issue
Block a user