Rec
VideoRecorder
Video Recorder (WIP)
Example
from tolvera import Tolvera, run, VideoRecorder def main(kwargs): tv = Tolvera(kwargs) vid = VideoRecorder(tv, **kwargs) @tv.cleanup def write(): vid.write() @tv.render def _(): vid() tv.px.diffuse(0.99) tv.v.flock(tv.p) tv.px.particles(tv.p, tv.s.species()) return tv.px
Source code in src/tolvera/rec.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
__call__(*args, **kwds)
__init__(tolvera, **kwargs)
Initialise a video recorder for a Tölvera program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolvera |
Tolvera
|
Tölvera instance to record. |
required |
f |
int
|
Number of frames to record. Defaults to 16. |
required |
r |
int
|
Ratio of frames to record (tv.ti.fps/r). Defaults to 4. |
required |
c |
int
|
Frame counter. Defaults to 0. |
required |
w |
int
|
Width of video. Defaults to tv.x. |
required |
h |
int
|
Height of video. Defaults to tv.y. |
required |
output_dir |
str
|
Output directory. Defaults to './output'. |
required |
filename |
str
|
Output filename. Defaults to 'output'. |
required |
automatic_build |
bool
|
Automatically build video. Defaults to True. |
required |
build_mp4 |
bool
|
Build mp4. Defaults to True. |
required |
build_gif |
bool
|
Build gif. Defaults to False. |
required |
clean_frames |
bool
|
Clean frames. Defaults to True. |
required |
Source code in src/tolvera/rec.py
clean()
Delete all previous image files in the saved directory.
Fixed version, see https://github.com/taichi-dev/taichi/issues/8533
Source code in src/tolvera/rec.py
dump(i)
Dump the current frame to the video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
i32
|
Frame index. |
required |
rec(i)
Record the current frame to the video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
i32
|
Frame index. |
required |
step()
Record the current frame and increment the frame counter.
write()
Write all frames to the video and build if necessary.
Source code in src/tolvera/rec.py
write_frame(i)
Write a frame to the video.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i |
int
|
Frame index. |
required |