Animation#
- class brainrender.video.Animation(scene, save_fld, name, fmt='mp4', size='1620x1050')[source]#
Bases:
VideoMakerFacilitate video creation via keyframes.
At each keyframe various parameters (e.g. camera position) are specified and the video is created by interpolating between consecutive keyframes.
Methods
add_keyframe(time[, duration, camera, zoom, ...])Add a keyframe to the video.
compress(temp_name)Compress the created video with ffmpeg and remove the uncompressed copy.
generate_frames(fps, duration, video, resetcam)Loop to generate frames.
get_frame_params(frame_number)Get interpolated parameters for a given frame number.
Convert keyframe times (seconds) to frame numbers.
make_video(**kwargs)- add_keyframe(time, duration=0, camera=None, zoom=None, interpol='sigma', callback=None, **kwargs)[source]#
Add a keyframe to the video.
- Parameters:
time (
float) – Time in seconds at which the keyframe takes place.duration (
float) – If >0 the keyframe is repeated every 5ms fromtimetotime + duration.camera (
dict|None) – Dictionary of camera parameters.zoom (
float|None) – Camera zoom level.interpol (
str) – Interpolation mode between keyframes:"sigma"or"linear".callback (
KeyframeCallback|None) – Function taking (scene, frame_number, total_frames) as arguments. Used to trigger actions during a keyframe (e.g. removing an actor).**kwargs (
Any) – Extra keyword arguments passed tocallback.
- Return type:
None
- compress(temp_name)#
Compress the created video with ffmpeg and remove the uncompressed copy.
- Parameters:
temp_name (
str) – Path (without extension) of the temporary uncompressed video.- Return type:
None
- generate_frames(fps, duration, video, resetcam)[source]#
Loop to generate frames.
- Parameters:
fps (
int) – Frame rate.duration (
float) – Video duration in seconds.video (
Video) – Vedo Video instance used to create the video.resetcam (
bool) – If True the camera is reset.
- Return type:
None
- get_frame_params(frame_number)[source]#
Get interpolated parameters for a given frame number.
If the frame is a keyframe or past the last keyframe, the corresponding keyframe params are returned directly. Otherwise params are interpolated using either a linear or sigmoid function.
- Parameters:
frame_number (
int) – Current frame number.- Returns:
Camera and zoom parameters for this frame.
- Return type:
dict
Convert keyframe times (seconds) to frame numbers.
- Parameters:
fps (
int) – Frame rate.- Return type:
None