started to clean up the mess

This commit is contained in:
kolaczyn
2020-06-24 23:39:23 +02:00
parent 5c58315f08
commit 0bb0341445
3 changed files with 53 additions and 42 deletions

47
gen-script.py Executable file
View File

@ -0,0 +1,47 @@
import re
import sys
from pathlib import Path
import os
import time
from datetime import datetime, timedelta
file_names = []
path = os.getcwd() + '/../subs/' # location of subtitles
for file_name in os.listdir(path):
file_names.append(file_name)
file_names.sort() # not necessary, but it makes generated files look better
data =[];
for f in file_names:
file = open(path+f)
for i, line in enumerate(file):
if re.search('(pesky|bird)', line):
data.append([f, prev[0:8], prev[17:25], line])
prev=line
for d in data:
print(d)
#
#
# datestring1 = data[-1][1]
# datestring2 = data[-1][2]
#
# #!!!! t1 = time.strptime(datestring1, "%M:%S")
# #!!!! t2 = time.strptime('00:12', '%M:%S')
# #!!!! start = time.mktime(t1)-time.mktime(t2)
# #!!!! print
#
# out_file = open('script.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')

42
main.py
View File

@ -1,42 +0,0 @@
import re
import sys
import os
import time
from datetime import datetime, timedelta
file_names = []
directory = r'/home/pawel/Videos/grian-pesky/subs/'
for file_name in os.listdir(directory):
file_names.append(file_name)
file_names.sort()
data =[]
for f in file_names:
file = open(directory+f)
for i, line in enumerate(file):
if re.search('(pesky|bird)', line):
data.append([f, prev[3:8], prev[20:25], line])
prev=line
for (t) in (data):
print(t)
print('-' * 10)
datestring1 = data[-1][1]
datestring2 = data[-1][2]
# t1 = time.strptime(datestring1, "%M:%S")
# t2 = time.strptime('00:12', '%M:%S')
# start = time.mktime(t1)-time.mktime(t2)
# print
out_file = open('script.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 -i ' + name + '.mp4 -ss 00:' + t[1] + ' -t 00:00:12 ' + ' -async 1 ' + vid_fil +'\n')

6
run.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
python gen-script.py
bash rip.bash
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4 # splice all the clips
rm list.txt rip.sh