Skip to content

make_video

thvid.make_video

Info

Video size for 1 minute video : https://video4change.org/the-basics-of-video-resolution/ - Ultra HD or 4K: 3840 x 2160 320 MB - Full HD : 1920x1080 149 MB - HD : 1280x720 105 MB - SD : 720x480 26 MB

Functions:

mknews_video_intro(vid_size=(1280, 720), lang='vi', rate=150, bg_video='default', bg_audio='default', bg_audio_factor=0.3, out_file='vid_intro.mp4')

Make INTRO video

Parameters:

  • vid_size (tuple, default: (1280, 720) ) –

    Video size.

  • lang (str, default: 'vi' ) –

    language of news

  • rate (float, default: 150 ) –

    speed of voice

  • bg_video (str, default: 'default' ) –

    filenames of video/image background. Possible: 'default', 'filename'

  • bg_audio (str, default: 'default' ) –

    file name of audio background. Possible: 'default', 'filename'

  • bg_audio_factor (float, default: 0.3 ) –

    factor of backgroun audio with main voice.

mknews_video_outro(vid_size=(1280, 720), lang='vi', rate=150, bg_video='default', bg_audio='default', bg_audio_factor=0.3, out_file='vid_outro.mp4')

Make OUTRO video Args: vid_size (tuple): Video size. lang (str): language of news rate (float): speed of voice bg_video (str): filenames of video/image background. Possible: 'default', 'filename' bg_audio (str): file name of audio background. Possible: 'default', 'filename' bg_audio_factor (float): factor of backgroun audio with main voice.

mknews_audio(file_text, lang='vi', rate=150, greet_word='', end_word='', out_file='audio_news.mp3')

create audio from file_text

Parameters:

  • file_text (str) –

    lain text file.

  • lang (str, default: 'vi' ) –

    language of news

  • greet_word (str, default: '' ) –

    Add speech at begin text. Possible: 'intro', 'middle', ''

  • end_word (str, default: '' ) –

    Add speech at begin text. Possible: 'outro', ''

Returns:

  • out_file ( Obj ) –

    audio file

mknews_1_video(lang='vi', rate=150, greet_word='', end_word='', vid_size=(1280, 720), img_duration=15, bg_video='', bg_audio='random', bg_audio_factor=0.2, out_file='vid_news.mp4')

Make a video with concept
  • put a text file and all videos, images into a folder
  • function will convert text to audio
  • make video base on length of audio
  • first use videos, if not enough duration then add images into video
  • if bg_video: make video with only background
    • random_short: use short videos from computer
    • random_download: random download long videos from a predefined list

Parameters:

  • lang (str, default: 'vi' ) –

    language of news

  • rate(float)

    speed of voice

  • vid_size (tuple, default: (1280, 720) ) –

    Video size.

  • img_duration (float, default: 15 ) –

    duration of an image in video.

  • bg_video (str, default: '' ) –

    filenames of video/image background. Possible: '', 'random_short', 'random_long'

  • bg_audio (str, default: 'random' ) –

    file name of audio background. Possible: "filename", 'random'

  • bg_audio_factor (float, default: 0.2 ) –

    factor of backgroun audio with main voice.

  • greet_word (str, default: '' ) –

    Add speech at begin text. Possible: 'intro', 'middle', ''

  • end_word (str, default: '' ) –

    Add speech at begin text. Possible: 'outro', ''

Note

video/image files should begin with a number to specify its order: '1_video_...' or '3_image_...' Only fist ".txt" files is used

mknews_lists_videos(sub_folder='news*', lang='vi', rate=150, greet_word='', end_word='', vid_size=(1280, 720), img_duration=15, bg_video='', bg_audio='', bg_audio_factor=0.2, padding=0, logo='STV', logo_pos='left', out_file='vid_all_news.mp4')

Make a videos in subfolder:

Parameters:

  • sub_folder (str, default: 'news*' ) –

    keyword to search subfolders.

  • bg_audio (str, default: '' ) –

    file name of audio background. Possible: "filename", 'random'

  • padding (float, default: 0 ) –

    gap between successive video

set_bg_audio(file_video, bg_audio='random', bg_audio_factor=0.2, keep_original=False)

Set background_audio for video

Parameters:

  • bg_audio (str, default: 'random' ) –

    file name of audio background. Possible: "filename", 'random'

  • bg_audio_factor (float, default: 0.2 ) –

    factor of backgroun audio with main voice.

  • keep_original (bool, default: False ) –

    keep original video or not

mknews_video_toc(sub_folder='news*', file_video_news='vid_news.mp4', vid_size=(1280, 720), bg_video='default', bg_audio='default', bg_audio_factor=0.3, border_factor=0.2, with_title=False, out_file='vid_TOC.mp4')

Make a TOC video:

Parameters:

  • sub_folder (str, default: 'news*' ) –

    keyword to search subfolders.

  • file_video_news (str, default: 'vid_news.mp4' ) –

    filename of breakingNews in each subfolder.

concate_audio_files(list_files, padding=0, out_file='concate_audio.mp3')

concate a list of audios

Parameters:

  • list_files (list) –

    list contains all audio files.

Returns:

  • file ( obj ) –

    audio file.

concate_video_files(list_files, padding=0, out_file='concate_videoNews.mp4')

concate a list of videos

Parameters:

  • list_files (list) –

    list contains all video files.

  • vid_size (tuple) –

    Video size.

Returns:

  • file ( obj ) –

    audio file.

add_logo_spokeman(file_video, vid_size=(1280, 720), logo='STV', logo_pos='left', spokeman='', spokeman_pos='left', h_spokeman=320, keep_original=False)

add Logo on videos

Parameters:

  • file_video (str) –

    video filename.

  • vid_size (tuple, default: (1280, 720) ) –

    Video size.

  • logo (str, default: 'STV' ) –

    Put logo on video. Possible: "N5_1", "N5_2", 'X7', 'STV', ""

  • logo_pos (float, default: 'left' ) –

    Position of logo. Possible: "left", "rigt"

  • spokeman (str, default: '' ) –

    Spokeman on video. Possible: '', 'Anonymous'

  • h_spokeman (float, default: 320 ) –

    height of Spokeman

  • background (str) –

    file name of video/image background. Possible: "filename", 'random'

  • bg_audio (str) –

    file name of audio background

split_video(video_file, n=3)

Split video into n parts

speech_word_by_word(text, lang='VN', rate=150, vol=1.0, audio_file='word_by_word.mp3')

speech_1_pair_lang(text1, text2, lang1='VN', lang2='EN', voice_name1='', voice_name2='', rate1=130, rate2=120, repeat_slow=60, repeat_fast=60, out_file='pair_lang_audio.mp3')

Returns:

  • file ( file ) –

    audio file, if out_file is not None.

  • clip_audio ( Obj ) –

    audio file, if out_file is None.

speech_list_pair_lang(df, lang1='VN', lang2='EN', rate1=130, rate2=120, repeat_slow=60, repeat_fast=60, out_file='pair_lang_audio_all.mp3')

Parameters:

  • df (DataFrame) –

    contains 2 columns for langs.

mkvid_1_pair_lang(text1, text2, lang1='VN', lang2='EN', voice_name1='', voice_name2='', rate1=130, rate2=120, repeat_slow=60, repeat_fast=60, vid_size=(1280, 720), font_size=80, text_color1='blue', text_color2='black', bg_color1='azure3', bg_color2='azure4', padding=1, show_flag=True, out_file='pair_lang.mp4')

Make a video with concept:

Args:

mkvid_list_pair_lang_from_df(df, lang1='VN', lang2='EN', voice_name1='', voice_name2='', rate1=130, rate2=120, repeat_slow=60, repeat_fast=60, vid_size=(1280, 720), font_size=80, text_color1='blue', text_color2='black', bg_color1='azure4', bg_color2='CadetBlue4', padding=1, show_flag=True, out_file='vid_pair_lang.mp4')

Parameters:

  • df (DataFrame) –

    contains 2 columns for langs.