Skip to content

Commit

Permalink
Update montaggio.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi99 committed Oct 28, 2021
1 parent 5979330 commit 55ebd2c
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions montaggio.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ def crea_montaggio(**kwargs):
zonaP = kwargs.get("zonaP", False)
start = kwargs.get("start", 0)
end = kwargs.get("end", 0)
set = kwargs.get("set", 0)
nome = kwargs.get("nome", "video")
max_counter = kwargs.get("max_counter", False)
rot = kwargs.get("rot", False)
rice = kwargs.get("rice", False)
fine_azione = kwargs.get("fine_azione", False)
for i, value in enumerate(rilev):
if max_counter and counter >= max_counter:
return
break
codice = value.Codice
try:
int(codice[1:3])
Expand All @@ -90,12 +92,34 @@ def crea_montaggio(**kwargs):
continue
if rot and value.ZPagg0 != rot:
continue
if rice and rilev[i-1].Codice[3] != "R":
continue
if rice and rice == "buona" and rilev[i-1].Codice[5] not in "#+":
continue
if rice and rice == "cattiva" and rilev[i-1].Codice[5] not in "!-":
continue
if fine_azione:
i2 = i
while True:
codice2 = rilev[i2].Codice
if codice2[1] == "p":
break
i2 += 1
t_fine_azione = rilev[i2].Millisec
else:
t_fine_azione = 4
if set:
if isinstance(set, list):
if value.Tempo not in set:
continue
else:
if value.Tempo != set:
continue
print(codice)
stream = ffmpeg.input(video_dir + video, ss=value.Millisec + start, t=4 + end)
if not fine_azione:
stream = ffmpeg.input(video_dir + video, ss=value.Millisec + start, t=t_fine_azione + end, hide_banner=None)
else:
stream = ffmpeg.input(video_dir + video, ss=value.Millisec + start, to=t_fine_azione + end, hide_banner=None)
stream = ffmpeg.output(stream, video_dir_tmp + f"{nome}_{counter}.mp4", vcodec="copy")
ffmpeg.run(stream, cmd="V:/Ruggi/Videos/Programmi/ffmpeg")
counter = counter + 1
Expand All @@ -105,7 +129,7 @@ def crea_montaggio(**kwargs):
with open(video_dir_tmp + "list.txt", "w") as f:
for i in range(counter):
f.write(f"file '{nome}_{i}.mp4'\n")
stream = ffmpeg.input(video_dir_tmp + "list.txt", f="concat", safe="0")
stream = ffmpeg.input(video_dir_tmp + "list.txt", f="concat", safe="0", hide_banner=None)
stream = ffmpeg.output(stream, video_dir + f"{nome}.mp4", vcodec="copy")
print(ffmpeg.compile(stream))
ffmpeg.run(stream, cmd="V:/Ruggi/Videos/Programmi/ffmpeg")
Expand Down

0 comments on commit 55ebd2c

Please sign in to comment.