def _make_round_credits( round_credits: RoundCredits, round_index: int, width: int, height: int, color: str = 'white', stroke_color: str = 'black', stroke_width: str = 2, font: str = 'Impact-Normal', fontsize: int = 60, gap: int = 0 ) -> Clip: texts = [] texts += [["\n", "\n"]] * 16 if round_credits.audio != []: texts += _make_credit_texts( str(round_credits.audio[0]), "ROUND {} MUSIC".format(round_index + 1)) for audio_credit in round_credits.audio[1:]: texts += _make_credit_texts(str(audio_credit)) if round_credits.video != []: texts += _make_credit_texts( str(round_credits.video[0]), "ROUND {} VIDEOS".format(round_index + 1)) for video_credit in round_credits.video[1:]: texts += _make_credit_texts(str(video_credit)) texts += [["\n", "\n"]] * 2 # Make two columns for the credits left, right = ("".join(t) for t in zip(*texts)) left, right = [TextClip(txt, color=color, stroke_color=stroke_color, stroke_width=stroke_width, font=font, fontsize=fontsize, align=al) for txt, al in [(left, 'East'), (right, 'West')]] # Combine the columns cc = CompositeVideoClip([left, right.set_position((left.w + gap, 0))], size=(left.w + right.w + gap, right.h), bg_color=None) scaled = resize(cc, width=width) # Scale to the required size # Transform the whole credit clip into an ImageClip credits_video = ImageClip(scaled.get_frame(0)) mask = ImageClip(scaled.mask.get_frame(0), ismask=True) lines_per_second = height / CREDIT_DISPLAY_TIME def scroll(t): return ("center", -lines_per_second * t) credits_video = credits_video.set_position(scroll) credits_duration = credits_video.h / lines_per_second credits_video = credits_video.set_duration(credits_duration) return credits_video.set_mask(mask)
#title_txt = TextClip(TITLE_TEXT,color=FONT_COLOR, align='West',fontsize=26, #font=FONT_FAMILY, method='label') if len(BACKGROUND_IMAGE) > 0: bg = ImageClip(BACKGROUND_IMAGE) # Scroll the text at the right speed line_height = 30 txt_speed = float(line_height) * float(txt_height) / float(duration) fl = lambda gf,t : gf(t)[int(txt_speed*t):int(txt_speed*t)+VIDEO_SIZE[1],:] moving_txt= text.fl(fl, apply_to=['mask']) # Create the video clip clip = CompositeVideoClip( [ vfx.resize(bg.set_position(BACKGROUND_IMAGE_POSITION), BACKGROUND_IMAGE_RESIZE), moving_txt.set_position(TEXT_POSITION) ] if len(BACKGROUND_IMAGE) > 0 else [ moving_txt.set_position(TEXT_POSITION) ], size=VIDEO_SIZE).\ on_color( color=BACKGROUND_COLOR, col_opacity=1).set_duration(duration).set_audio(audio) clip.write_videofile(OUTPUT_FILE, fps=10) #use_bgclip=True if len(BACKGROUND_IMAGE) > 0 else False,