(Created page with "= Videogrep = the following scripts are from: http://zulko.github.io/blog/2014/06/21/some-more-videogreping-with-python/ == Peter Sunde, constructed sentence: "We lost, th...")
Making a short summary of the keynote, by using the automatic generated srt file from youtube, by using:
youtube-dl --write-auto-sub --srt-lang en [URL]
and adding a little 'letter-code' into it (here: xyz), for the sentences that should be included.
14
00:00:48,329 --> 00:00:51,709 xqz a critical mass that are upset with the
current state of the internet
importre# module for regular expressionsdefconvert_time(timestring):""" Converts a string into seconds """nums=map(float,re.findall(r'\d+',timestring))return3600*nums[0]+60*nums[1]+nums[2]+nums[3]/1000withopen("transmediale-annotation.srt")asf:lines=f.readlines()times_texts=[]current_times,current_text=None,""forlineinlines:times=re.findall("[0-9]*:[0-9]*:[0-9]*,[0-9]*",line)iftimes!=[]:current_times=map(convert_time,times)elifline=='\n':times_texts.append((current_times,current_text))current_times,current_text=None,""elifcurrent_timesisnotNone:current_text=current_text+line.replace("\n"," ")print(times_texts)fromcollectionsimportCounterwhole_text=" ".join([textfor(time,text)intimes_texts])all_words=re.findall("\w+",whole_text)counter=Counter([w.lower()forwinall_wordsiflen(w)>5])print(counter.most_common(10))cuts=[timesfor(times,text)intimes_textsif(re.findall("xqz",text)!=[])]frommoviepy.editorimportVideoFileClip,concatenatevideo=VideoFileClip("transmediale-opening-peter-sunde.mp4")defassemble_cuts(cuts,outputfile):""" Concatenate cuts and generate a video file. """final=concatenate([video.subclip(start,end)for(start,end)incuts])final.to_videofile(outputfile)assemble_cuts(cuts,"transmediale-annotation-02.1.mp4")