sitcom_simulator.video.integrations.ffmpeg¶
Functions
|
Combines the given video clips into a single video file and returns the path to the concatenated video file. |
|
Renders a video clip from the given clip object and returns the path to the rendered video file. |
|
Renders a video from the given script and returns the path to the rendered video file. |
Classes
|
Settings for boxes in a video. |
|
Settings for captions in a video. |
|
Settings for rendering video clips. |
|
Settings for shadows in a video. |
- class sitcom_simulator.video.integrations.ffmpeg.ShadowSettings(color='black', alpha=0.7, x=5, y=5)¶
Settings for shadows in a video.
- Parameters:
color (
str
) – The color of the shadowalpha (
float
) – The alpha of the shadowx (
int
) – The x offset of the shadowy (
int
) – The y offset of the shadow
-
color:
str
= 'black'¶
-
alpha:
float
= 0.7¶
-
x:
int
= 5¶
-
y:
int
= 5¶
- to_dict()¶
Returns a dictionary representation of the shadow settings for use in an FFmpeg filter.
- __init__(color='black', alpha=0.7, x=5, y=5)¶
- Parameters:
color (str)
alpha (float)
x (int)
y (int)
- Return type:
None
- class sitcom_simulator.video.integrations.ffmpeg.BoxSettings(color='black', alpha=0.5, border_width=10)¶
Settings for boxes in a video.
- Parameters:
color (
str
) – The color of the boxalpha (
float
) – The alpha of the boxborder_width (
int
) – The width of the box border
-
color:
str
= 'black'¶
-
alpha:
float
= 0.5¶
-
border_width:
int
= 10¶
- to_dict()¶
Returns a dictionary representation of the box settings for use in an FFmpeg filter.
- __init__(color='black', alpha=0.5, border_width=10)¶
- Parameters:
color (str)
alpha (float)
border_width (int)
- Return type:
None
- class sitcom_simulator.video.integrations.ffmpeg.CaptionSettings(font='Arial', max_width=30, y_ratio_from_bottom=0.25)¶
Settings for captions in a video.
- Parameters:
font (
str
) – The path to the font file to use for the captionsmax_width (
int
) – The maximum width of the captions, in charactersy_ratio_from_bottom (
float
) – The y ratio from the bottom of the screen to place the captions
-
font:
str
= 'Arial'¶
-
max_width:
int
= 30¶
-
y_ratio_from_bottom:
float
= 0.25¶
Renders a caption with the given text and returns the caption string.
- Parameters:
text (
str
) – The text of the captionwidth – The width of the video
height – The height of the video
- __init__(font='Arial', max_width=30, y_ratio_from_bottom=0.25)¶
- Parameters:
font (str)
max_width (int)
y_ratio_from_bottom (float)
- Return type:
None
- class sitcom_simulator.video.integrations.ffmpeg.ClipSettings(clip_buffer_seconds=0.15, min_clip_seconds=1.5, speaking_delay_seconds=0.12, max_zoom_factor=1.3, min_zoom_factor=1.05, max_pan_speed=6)¶
Settings for rendering video clips.
- Parameters:
clip_buffer_seconds (
float
) – How much time to wait after characters finish talkingmin_clip_seconds (
float
) – The minimum time to hold on a clipspeaking_delay_seconds (
float
) – Delay before the audio kicks inmax_zoom_factor (
float
) – The maximum zoom factor for the pan and zoom effectmin_zoom_factor (
float
) – The minimum zoom factor for the pan and zoom effect. At least some zoom is necessary for panning.max_pan_speed (
float
) – The maximum speed of the pan and zoom effect
-
clip_buffer_seconds:
float
= 0.15¶
-
min_clip_seconds:
float
= 1.5¶
-
speaking_delay_seconds:
float
= 0.12¶
-
max_zoom_factor:
float
= 1.3¶
-
min_zoom_factor:
float
= 1.05¶
-
max_pan_speed:
float
= 6¶
- __init__(clip_buffer_seconds=0.15, min_clip_seconds=1.5, speaking_delay_seconds=0.12, max_zoom_factor=1.3, min_zoom_factor=1.05, max_pan_speed=6)¶
- Parameters:
clip_buffer_seconds (float)
min_clip_seconds (float)
speaking_delay_seconds (float)
max_zoom_factor (float)
min_zoom_factor (float)
max_pan_speed (float)
- Return type:
None
- sitcom_simulator.video.integrations.ffmpeg.render_clip(clip, width=720, height=1280, speed=1.0, pan_and_zoom=True, clip_settings=ClipSettings(clip_buffer_seconds=0.15, min_clip_seconds=1.5, speaking_delay_seconds=0.12, max_zoom_factor=1.3, min_zoom_factor=1.05, max_pan_speed=6), caption_settings=CaptionSettings(font='Arial', max_width=30, y_ratio_from_bottom=0.25), caption_bg_settings=BoxSettings(color='black', alpha=0.5, border_width=10), audio_codec='mp3')¶
Renders a video clip from the given clip object and returns the path to the rendered video file.
- Parameters:
clip (
Clip
) – The clip to renderwidth (
int
) – The width of the videoheight (
int
) – The height of the videospeed (
float
) – The speed of the final video. 1.0 is normal speedpan_and_zoom (
bool
) – If True, the pan and zoom effect on images will be enabledclip_settings (
ClipSettings
) – The settings for rendering the video clipcaption_settings (
CaptionSettings
) – The settings for the captionscaption_bg_settings (
BoxSettings
|ShadowSettings
) – The settings for the caption backgroundaudio_codec (
Literal
['mp3'
,'aac'
]) – The audio codec to use for the output video
- sitcom_simulator.video.integrations.ffmpeg.concatenate_clips(filenames, output_filename, background_music=None, bgm_volume=-24, audio_codec='mp3')¶
Combines the given video clips into a single video file and returns the path to the concatenated video file.
- Parameters:
filenames (
List
[str
]) – The list of video file paths to combineoutput_filename (
str
) – The name of the output filebackground_music (
str
|None
) – The path to the background music filebgm_volume (
float
) – The volume of the background music, between 0 and 1audio_codec (
Literal
['mp3'
,'aac'
]) – The audio codec to use for the output video
- sitcom_simulator.video.integrations.ffmpeg.render_video(script, output_path='output.mp4', width=720, height=1280, speed=1.0, pan_and_zoom=True, clip_settings=ClipSettings(clip_buffer_seconds=0.15, min_clip_seconds=1.5, speaking_delay_seconds=0.12, max_zoom_factor=1.3, min_zoom_factor=1.05, max_pan_speed=6), caption_settings=CaptionSettings(font='Arial', max_width=30, y_ratio_from_bottom=0.25), caption_bg_settings=BoxSettings(color='black', alpha=0.5, border_width=10), bgm_volume=-24, audio_codec='mp3')¶
Renders a video from the given script and returns the path to the rendered video file.
At present, only 9:16 aspect ratio is supported, but 16:9 and 1:1 will be supported in the future.
- Parameters:
script (
Script
) – The script to renderoutput_path (
str
) – The path to save the rendered videowidth (
int
) – The width of the videoheight (
int
) – The height of the videospeed (
float
) – The speed of the final video. 1.0 is normal speedpan_and_zoom (
bool
) – If True, the pan and zoom effect on images will be enabledclip_settings (
ClipSettings
) – The settings for rendering the video clipcaption_settings (
CaptionSettings
) – The settings for the captionscaption_bg_settings (
BoxSettings
|ShadowSettings
) – The settings for the caption backgroundbgm_volume (
float
) – The volume of the background music, good values are between -24 and -16audio_codec (
Literal
['mp3'
,'aac'
]) – The audio codec to use for the output video