def from_generators(gif_file_name, feeding_data, how_many_images_to_generate, image_generator): frames = [] duration_pre_image = 0.5 feeding_angle = feeding_data.steering_angle for index in range(how_many_images_to_generate): image, angle = image_generator(feeding_data) text = TextClip(txt="angle:{:.2f}/{:.2f}".format(feeding_angle, angle), method="caption", align="North", color="white", stroke_width=3, fontsize=18) text = text.set_duration(duration_pre_image) frames.append(CompositeVideoClip([ ImageClip(image, duration=duration_pre_image), text ])) final = concatenate_videoclips(frames) final.write_gif(gif_file_name, fps=2)
def video_from_datasets(gif_file_name, dataset): frames = [] duration_pre_image = 0.5 feeding_angle = 1. #feeding_data.steering_angle index = 0 total = len(dataset.records) for feeding_data in dataset.records: index = index + 1 if index % 10 == 0: print("working {}/{}".format(index + 1, total)) image, angle = feeding_data.image(), feeding_data.steering_angle text = TextClip(txt="angle:{:.2f}/{:.2f}".format(feeding_angle, angle), method="caption", align="North", color="white", stroke_width=3, fontsize=18) text = text.set_duration(duration_pre_image) frames.append(CompositeVideoClip([ ImageClip(image, duration=duration_pre_image), text ])) final = concatenate_videoclips(frames) final.write_videofile(gif_file_name, fps=2)
def processLine(index, rawline, temp): line = processCommentsAndSpaces(rawline, temp) if not line: temp['empty'] += 1 elif line[:2] == '>>': processNewVideoLine(line, temp) elif line[:1] == '$': # text clip textClip = TextClip(line[1:], bg_color='black', fontsize=75, color='white') textDetails = ClipDetails("", 0, 2, line[1:]) textDetails.clip = textClip.set_duration(2) clipDetailsList.append(textDetails) else: if validTimeWindow(line, index): details = ClipDetails(temp['currentVideo'], line.split('-')[0], line.split('-')[1], "") clipDetailsDict[temp['currentVideo']].append(details) clipDetailsList.append(details)
def from_folder(folder, file_name): frames = [] duration_pre_image = 0.1 drive_records = glob(folder) total = len(drive_records) for index in range(0, total, 2): print("working {}/{}".format(index + 1, total)) record = drive_records[index] image = np.array(Image.open(record)) text = TextClip(txt="steps_{}".format(basename(record)), method="caption", align="North", color="white", stroke_width=3, fontsize=18) text = text.set_duration(duration_pre_image) center_image_clip = ImageClip(image, duration=duration_pre_image) all_images_clip = clips_array([[center_image_clip]]) frames.append(CompositeVideoClip([ all_images_clip, text ])) final = concatenate_videoclips(frames, method="compose") final.write_videofile(file_name, fps=10)
def from_udacity_sample_data(drive_records, file_name): frames = [] duration_pre_image = 0.1 total = len(drive_records) for index in range(0, total, 2): print("working {}/{}".format(index + 1, total)) record = drive_records[index] image, angle = record.image(), record.steering_angle text = TextClip(txt="angle:{:.2f}".format(angle), method="caption", align="North", color="white", stroke_width=3, fontsize=18) text = text.set_duration(duration_pre_image) center_image_clip = ImageClip(image, duration=duration_pre_image) left_image_clip = ImageClip(record.left_image(), duration=duration_pre_image) right_image_clip = ImageClip(record.right_image(), duration=duration_pre_image) all_images_clip = clips_array([[center_image_clip], [left_image_clip], [right_image_clip]]) frames.append(CompositeVideoClip([ all_images_clip, text ])) final = concatenate_videoclips(frames) final.write_videofile(file_name, fps=10)
run([ "mp3info", "-p", "% S", f'{path}/audio/HEADLINES/{headline_audio}' ], capture_output=True, text=True).stdout) + 1 healine_txt = f'{num}.\n\n{videos[:-4]}' text_clip = TextClip(healine_txt, size=(1024, 200), color='white', font='ADAM.CG PRO', kerning=2, method='caption', align='center').set_pos("center") text_clip = text_clip.set_duration(audio_duration) text_clip = text_clip.set_audio(audio) video_clip = VideoFileClip(f'../{videos}') video_duration = video_clip.duration isf_logo = ImageClip( '/home/sr1/Projects/Others/videoAUTO/scripts/mediaFiles/isf.png' ).set_duration(video_duration) render = CompositeVideoClip([ video_clip.set_start(audio_duration), isf_logo.set_start(audio_duration).set_pos(('left', 'bottom')), text_clip.crossfadein(1).crossfadeout(1) ], bg_color=[128, 0, 0])
video_clip = VideoFileClip(source_video_path) # another audio file to clip background_audio_clip = AudioFileClip(source_audio_path) # creating text clip text = ''' This clip shows how to open terminal. ''' intro_duration = 5 intro_text = TextClip(txt=text, color='white', fontsize=70, size=video_clip.size) intro_text = intro_text.set_fps(video_clip.fps) intro_text = intro_text.set_duration(intro_duration) intro_text = intro_text.set_position('center') intro_music = background_audio_clip.subclip(t_start=0, t_end=intro_duration) intro_text = intro_text.set_audio(intro_music) intro_video_dir = os.path.join(overlay_text_dir, 'intro-video.mp4') intro_text.write_videofile(intro_video_dir) # overlaying text on the original video w, h = video_clip.size watermark_text = TextClip(txt='CFE', fontsize=30, align='East', color='white', size=(w, 30))
#animation = VideoClip(make_frame, duration=5).resize(width=800,height=600) animation = VideoClip(make_frame, duration=10) #animation.write_gif('otto.gif', fps=2, opt='OptimizePlus') animation.write_videofile("surfVideo.webm",preset="medium",fps=20,audio=False) ######### close canvas only here ... app.process_events() canvas.close() app.process_events() app.quit() #try to create sound version ... audioclip = AudioFileClip("../data/zkmaudio.wav") videoclip = VideoFileClip("surfVideo.webm") l = videoclip.duration print("video length:",l) audio = audioclip.set_duration(l) # same length as video videoclip.set_audio(audio) #textclip = TextClip("ZKM Open Codes", fontsize=20, color='white').set_pos("center","center") # get font list with: #TextClip.list("font") # we could also add the text directly, see above textclip = TextClip("ZKM Open Codes", font="FreeSans",fontsize=40, color='white',method='label') t = textclip.set_duration(l) # compose everything. make sure to set audio here! finalclip = CompositeVideoClip([videoclip.set_audio(audio),t.set_pos("center","center")]) finalclip.write_videofile("surfVideo_sound.webm",preset="medium",fps=20)