edith
Clone
https://git.tahinli.com/Tahinli/edith.git
0 watching0 forksRust18.3 MiB6a8d990Tahinli15 days ago1049 commits
| 1 | //! Render preview: a stretch of the timeline pre-rendered once into a picture |
| 2 | //! file at preview size, so that playback over it reads frames instead of |
| 3 | //! compositing them -- the heavy sections (stacked effects, titles over video, |
| 4 | //! colour, speed, multicam) are the ones that drop frames live. |
| 5 | //! |
| 6 | //! The rules, and they are the whole contract: |
| 7 | //! |
| 8 | //! - **Content-keyed, never stale.** A segment is named by a hash of everything |
| 9 | //! that can change its pixels in its range: the clips that overlap it (and the |
| 10 | //! neighbours either side, whose transitions reach into it), their sources' |
| 11 | //! files, the titles and captions over it, the lanes' visibility, the tone and |
| 12 | //! the frame rate. Any edit that changes those drops the segment by name: a |
| 13 | //! changed hash is a file nothing looks for. Nothing is ever compared by time. |
| 14 | //! - **Derived, never authoritative.** Deleting the render directory costs the |
| 15 | //! time to render again and nothing else. Nothing in a project file names a |
| 16 | //! segment; the directory is scanned and each file is checked against the |
| 17 | //! hash of the timeline as it is now ([`segments`]). |
| 18 | //! - **Picture at preview size.** Rendered through [`crate::export`] over the |
| 19 | //! range, at [`crate::proxy::size_for`] of the project, every frame a random |
| 20 | //! access point. Playback scales it to the viewer like any other picture. |
| 21 | //! Sound is not used from here; the live mix always plays. |
| 22 | //! |
| 23 | //! Files are named `{from}-{to}-{width}x{height}-{key:016x}.mp4` in the user's |
| 24 | //! cache under `edith/renders`. The `.part` while it is written is what an |
| 25 | //! export writes beside its output, and the rename is the finish. |
| 26 | |
| 27 | use ; |
| 28 | use UNIX_EPOCH; |
| 29 | |
| 30 | use crate; |
| 31 | use crate; |
| 32 | use crate; |
| 33 | |
| 34 | /// One rendered stretch that still matches the timeline: frames `from..to`. |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | /// Where renders live, or `None` where the machine has no cache directory. |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// What a file on disk says about itself, for the content key: its path, its |
| 54 | /// length and its modification time. A source that moved or changed is a |
| 55 | /// different key. |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | /// The hash of everything that can change the pixels of `from..to` at `size`. |
| 71 | /// |
| 72 | /// Each clip that overlaps the range is hashed whole (its effects, keys, colour, |
| 73 | /// transform, fades and transitions are all in its `Debug`), and so is the one |
| 74 | /// clip either side of the range in every lane: a transition out of the clip |
| 75 | /// before reaches into the range, and the clip after is what it blends into. |
| 76 | /// Captions and titles are hashed whole when they overlap, and so is the tone. |
| 77 | /// Over-keying is safe here -- an extra hash change only costs a re-render -- |
| 78 | /// so the rule is kept simple rather than exact. |
| 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 | /// The inverse of [`name`]: `None` for anything else in the directory. |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | /// Every rendered segment that still matches `project` as it is now, in |
| 132 | /// timeline order. A file whose hash no longer matches is simply not returned; |
| 133 | /// it is left for [`delete_all`] to take. |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | /// The segment that holds timeline frame `frame`, if one matches now. |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | /// A render being made, or one that was already there. Poll |
| 166 | /// [`progress`](Job::progress) while [`is_finished`](Job::is_finished) is false |
| 167 | /// and take the [`outcome`](Job::outcome) when it flips, as a proxy is polled. |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | /// Starts rendering `from..to` of `project` (clamped to its end), or hands back |
| 207 | /// the segment already there. The frames are the ones the project plays: the |
| 208 | /// render is an export of the range at [`crate::proxy::size_for`] the project. |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | /// Deletes every render, finished or half written, and says how many files went. |
| 248 | /// Nothing else in the cache directory is ever named by this module. |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | /// Whether a clip carries anything that a render would be paying for: an effect, |
| 274 | /// a colour or transform, a key, a fade or a transition, or a speed change. |
| 275 | /// Used by the bar that marks the stretches worth rendering. |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | |
| 342 | |
| 343 | |
| 344 | |
| 345 | |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 |