after refactoring, it works!

This commit is contained in:
kolaczyn
2020-06-25 00:27:18 +02:00
parent 09553ed73c
commit b4aa216c99
2 changed files with 14 additions and 12 deletions

View File

@ -4,12 +4,13 @@ from pathlib import Path
import os
import time
from datetime import datetime, timedelta
# jargon explanation: rip - 10-20 second part of a video
# # TODO:
# remove not used imports
# searched string is hardcoded. fix that
# make it so the script rips ~10 second before the subtitle and 10 seconds after
# implement overlaping chunks recognition
# use regex instead of hardcoding
path = os.getcwd() + '/../subs/' # subtitles location
file_names = []
@ -35,13 +36,13 @@ for f in file_names:
# #!!!! start = time.mktime(t1)-time.mktime(t2)
# #!!!! print
#
# out_file = open('rip.sh', 'w')
# out_list = open('list.txt', 'w')
# for (i, t) in enumerate(data):
# name = t[0][:2]
# vid_fil = 'out/'+ name + '-' + str(i)+'.mp4'
# out_list.write('file \'' + vid_fil + "'\n")
# out_file.write('ffmpeg -ss ' + t[1] + ' -i ' + name + '.mp4 -to ' + '00:00:12' + ' -c copy out/' + name + '-' + str(i) + '.mp4\n' )
#
# os.system('bash script.sh')
# #!!!!os.system('ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4')
# TODO I am using enumerato to make it so different rips from the same video
# have a different name and are in order. the order won't work if there is more
# than 9 rips from the same video
file_rip = open('rip.sh', 'w')
file_list = open('list.txt', 'w')
for (i, d) in enumerate(data):
name = d['fname'][:2] # get a name without an extension, eg. 02.srt -> 02
outname = '../out/' + name + '-' + str(i) + ".mp4" # name of a rip, eg ../out/02-4.mp4
file_list.write("file '" + outname + "''\n") # TODO use {} or %s instead of +
file_rip .write('ffmpeg -ss ' + d['beg'] + ' -i ../original/' + name + '.mp4 -to ' + '00:00:12' + ' -c copy ' +outname+'\n')