A Proxies switch in the panel, and the stand-ins made without being asked
Browse files at this commit892f81332dd94f32ffbbd87939b66adc5da2e4c0Parent: 79c69dd- feat
- a Proxies switch in the panel, and the stand-ins made without being asked
12 changed files +294 -4
- crates/app/src/export_ui.rs +7 -0
- crates/app/src/importing.rs +37 -0
- crates/app/src/keymap.rs +18 -1
- crates/app/src/layout.rs +5 -0
- crates/app/src/main.rs +7 -0
- crates/app/src/player/actions.rs +1 -0
- crates/app/src/player/export.rs +45 -0
- crates/app/src/player/library.rs +111 -0
- crates/app/src/render.rs +5 -0
- crates/app/src/ui/inspector.rs +18 -0
- crates/app/src/ui/library.rs +10 -0
- crates/engine/src/proxy.rs +30 -3
crates/app/src/export_ui.rsmodified+7 -0
| @@ -645,6 +645,13 @@ pub(crate) fn export_settings( | |||
| 645 | // caller that writes a file; the rest of them are asking about the | 645 | // caller that writes a file; the rest of them are asking about the |
| 646 | // bitrate and the format. | 646 | // bitrate and the format. |
| 647 | subtitles: Vec::new(), | 647 | subtitles: Vec::new(), |
| 648 | + // Neither is a delivery setting: both belong to the stand-ins | ||
| 649 | + // [`engine::proxy`] writes -- every frame a key frame costs bits | ||
| 650 | + // nobody delivering wants, and a file kept in its source's colour | ||
| 651 | + // space is one for this editor to read back rather than to hand | ||
| 652 | + // anybody. | ||
| 653 | + intra_only: false, | ||
| 654 | + keep_source_colour: false, | ||
| 648 | } | 655 | } |
| 649 | } | 656 | } |
| 650 | 657 | ||
crates/app/src/importing.rsmodified+37 -0
| @@ -62,6 +62,43 @@ pub(crate) enum Wave { | |||
| 62 | Peaks(Arc<Vec<(f32, f32)>>), | 62 | Peaks(Arc<Vec<(f32, f32)>>), |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | +/// What a source's stand-in is up to ([`engine::proxy`]). Kept per file and | ||
| 66 | +/// filled like every other library fact -- presence means "asked", so a repaint | ||
| 67 | +/// mid-encode cannot start a second one. | ||
| 68 | +pub(crate) enum Proxy { | ||
| 69 | + /// The header is being read to find out whether this file wants one. Its | ||
| 70 | + /// own state because it is what makes "how many are in flight" a number: | ||
| 71 | + /// the answer comes back on a worker, and until it does this file may still | ||
| 72 | + /// turn into an encode. | ||
| 73 | + Asked, | ||
| 74 | + /// A file this machine cuts at speed as it is: no stand-in, and none | ||
| 75 | + /// wanted ([`engine::proxy::wanted`]). | ||
| 76 | + Native, | ||
| 77 | + /// Being made, in the background, while the film keeps playing. | ||
| 78 | + Making(engine::proxy::Job), | ||
| 79 | + /// There is one in the cache. What the switch actually plays. | ||
| 80 | + Ready, | ||
| 81 | + /// It could not be made: the film itself is what plays, and the row says | ||
| 82 | + /// so rather than leaving a bar that never fills. | ||
| 83 | + Failed, | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +impl Proxy { | ||
| 87 | + /// What the library row says about it, or nothing at all for a file that | ||
| 88 | + /// never wanted one -- a row per source is not the place to announce that | ||
| 89 | + /// nothing is happening. | ||
| 90 | + pub(crate) fn detail(&self) -> String { | ||
| 91 | + match self { | ||
| 92 | + Self::Asked | Self::Native => String::new(), | ||
| 93 | + // Rounded down: a bar that says 100% while the encoder is still | ||
| 94 | + // writing is the one number a progress line must never show. | ||
| 95 | + Self::Making(job) => format!("proxy {}%", (job.progress() * 100.) as u32), | ||
| 96 | + Self::Ready => "proxy".to_string(), | ||
| 97 | + Self::Failed => "no proxy".to_string(), | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | +} | ||
| 101 | + | ||
| 65 | /// The import a worker is reading, as the line above the panel shows it. No | 102 | /// The import a worker is reading, as the line above the panel shows it. No |
| 66 | /// fraction anywhere: neither read reports how far into the file it has come, | 103 | /// fraction anywhere: neither read reports how far into the file it has come, |
| 67 | /// so what is honest is the file's name, the stage, and two clocks -- one that | 104 | /// so what is honest is the file's name, the stage, and two clocks -- one that |
crates/app/src/keymap.rsmodified+18 -1
| @@ -110,6 +110,11 @@ actions! { | |||
| 110 | Mix, | 110 | Mix, |
| 111 | ToggleSnap, | 111 | ToggleSnap, |
| 112 | ToggleSubtitles, | 112 | ToggleSubtitles, |
| 113 | + /// Cut on the stand-ins or on the films themselves | ||
| 114 | + /// ([`engine::proxy`]): what the picture is decoded from, and nothing | ||
| 115 | + /// else -- the sound and every export stay the film's whichever way it | ||
| 116 | + /// is set. | ||
| 117 | + ToggleProxies, | ||
| 113 | /// The window's own colours, which belong to the person looking at them and | 118 | /// The window's own colours, which belong to the person looking at them and |
| 114 | /// not to the project: a list of the palettes, opened here and from the | 119 | /// not to the project: a list of the palettes, opened here and from the |
| 115 | /// toolbar's Theme button. It was a build feature once, which made it a | 120 | /// toolbar's Theme button. It was a build feature once, which made it a |
| @@ -173,6 +178,7 @@ impl ActionId { | |||
| 173 | ActionId::Mix => "Mix: track volumes and the limiter…", | 178 | ActionId::Mix => "Mix: track volumes and the limiter…", |
| 174 | ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)", | 179 | ActionId::ToggleSnap => "Snap on / off (edges, the playhead, the start)", |
| 175 | ActionId::ToggleSubtitles => "Subtitles on / off over the picture", | 180 | ActionId::ToggleSubtitles => "Subtitles on / off over the picture", |
| 181 | + ActionId::ToggleProxies => "Proxies on / off for the picture", | ||
| 176 | ActionId::Theme => "Theme: the window's colours…", | 182 | ActionId::Theme => "Theme: the window's colours…", |
| 177 | ActionId::CancelExport => "Cancel export", | 183 | ActionId::CancelExport => "Cancel export", |
| 178 | ActionId::ShowActions => "All actions and their keys…", | 184 | ActionId::ShowActions => "All actions and their keys…", |
| @@ -227,6 +233,7 @@ impl ActionId { | |||
| 227 | ActionId::Mix => "mix", | 233 | ActionId::Mix => "mix", |
| 228 | ActionId::ToggleSnap => "toggle-snap", | 234 | ActionId::ToggleSnap => "toggle-snap", |
| 229 | ActionId::ToggleSubtitles => "toggle-subtitles", | 235 | ActionId::ToggleSubtitles => "toggle-subtitles", |
| 236 | + ActionId::ToggleProxies => "toggle-proxies", | ||
| 230 | ActionId::Theme => "theme", | 237 | ActionId::Theme => "theme", |
| 231 | ActionId::CancelExport => "cancel-export", | 238 | ActionId::CancelExport => "cancel-export", |
| 232 | ActionId::ShowActions => "show-actions", | 239 | ActionId::ShowActions => "show-actions", |
| @@ -279,6 +286,10 @@ impl ActionId { | |||
| 279 | | ActionId::ZoomOut | 286 | | ActionId::ZoomOut |
| 280 | | ActionId::ZoomFit | 287 | | ActionId::ZoomFit |
| 281 | | ActionId::ToggleSubtitles | 288 | | ActionId::ToggleSubtitles |
| 289 | + // ...and which file the picture is decoded from, which changes | ||
| 290 | + // nothing that is saved and nothing that is exported: a stand-in | ||
| 291 | + // is what one watches while cutting, not what one delivers. | ||
| 292 | + | ActionId::ToggleProxies | ||
| 282 | // ...and what the whole window is painted in: it edits nothing at | 293 | // ...and what the whole window is painted in: it edits nothing at |
| 283 | // all, it is what one is looking *with*. | 294 | // all, it is what one is looking *with*. |
| 284 | | ActionId::Theme => Category::View, | 295 | | ActionId::Theme => Category::View, |
| @@ -811,6 +822,11 @@ impl Keymap { | |||
| 811 | // the rest of the things one *looks* at, and nowhere near the | 822 | // the rest of the things one *looks* at, and nowhere near the |
| 812 | // two keys that delete. | 823 | // two keys that delete. |
| 813 | b(ActionId::ToggleSubtitles, "t", false), | 824 | b(ActionId::ToggleSubtitles, "t", false), |
| 825 | + // The stand-ins take ctrl+p, the p of the word: the unshifted | ||
| 826 | + // one is the fit policy, and a ctrl chord is right for a switch | ||
| 827 | + // thrown once for a whole session rather than one wanted under | ||
| 828 | + // a hand -- the theme takes ctrl+h for that reason. | ||
| 829 | + b(ActionId::ToggleProxies, "p", true), | ||
| 814 | // The theme takes ctrl+h -- the h of the word, since "t" is the | 830 | // The theme takes ctrl+h -- the h of the word, since "t" is the |
| 815 | // subtitles and ctrl+t takes one off -- and a ctrl chord because | 831 | // subtitles and ctrl+t takes one off -- and a ctrl chord because |
| 816 | // it is a preference set once, not a stroke wanted under a hand | 832 | // it is a preference set once, not a stroke wanted under a hand |
| @@ -1085,7 +1101,8 @@ mod tests { | |||
| 1085 | #[test] | 1101 | #[test] |
| 1086 | fn every_default_stroke_reaches_its_action() { | 1102 | fn every_default_stroke_reaches_its_action() { |
| 1087 | let k = Keymap::defaults(); | 1103 | let k = Keymap::defaults(); |
| 1088 | - assert_eq!(k.entries().len(), 49); | 1104 | + assert_eq!(k.entries().len(), 50); |
| 1105 | + assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); | ||
| 1089 | assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); | 1106 | assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); |
| 1090 | assert_eq!(k.lookup("h", true), Some(ActionId::Theme)); | 1107 | assert_eq!(k.lookup("h", true), Some(ActionId::Theme)); |
| 1091 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); | 1108 | assert_eq!(k.lookup("space", false), Some(ActionId::Play)); |
crates/app/src/layout.rsmodified+5 -0
| @@ -38,6 +38,11 @@ pub(crate) const LABEL_MIN_W: f32 = 36.; | |||
| 38 | /// a shape. Ceiling: [`View::max_zoom`]'s 8 frames across the bed. The upgrade | 38 | /// a shape. Ceiling: [`View::max_zoom`]'s 8 frames across the bed. The upgrade |
| 39 | /// is a second, finer pass over the visible span only, cached like `waves` is. | 39 | /// is a second, finer pass over the visible span only, cached like `waves` is. |
| 40 | pub(crate) const WAVE_BPS: u32 = 40; | 40 | pub(crate) const WAVE_BPS: u32 = 40; |
| 41 | +/// How many stand-ins ([`engine::proxy`]) may be in flight at once. Two, not | ||
| 42 | +/// one per core: each is a whole film through a decoder and an encoder, and the | ||
| 43 | +/// hardware seat they queue on is a single one -- more of them at once is the | ||
| 44 | +/// same work done later, with the editor slower while it happens. | ||
| 45 | +pub(crate) const PROXIES_AT_ONCE: usize = 2; | ||
| 41 | /// Pixels per envelope column. Coarser than a pixel: the eye reads the shape, | 46 | /// Pixels per envelope column. Coarser than a pixel: the eye reads the shape, |
| 42 | /// and a path with a point per pixel is a path per repaint. | 47 | /// and a path with a point per pixel is a path per repaint. |
| 43 | pub(crate) const WAVE_COL: f32 = 2.; | 48 | pub(crate) const WAVE_COL: f32 = 2.; |
crates/app/src/main.rsmodified+7 -0
| @@ -149,6 +149,12 @@ struct Player { | |||
| 149 | /// the key is inserted the moment the decode is *started*: presence means | 149 | /// the key is inserted the moment the decode is *started*: presence means |
| 150 | /// "asked", so a repaint mid-decode cannot ask again. | 150 | /// "asked", so a repaint mid-decode cannot ask again. |
| 151 | waves: HashMap<(PathBuf, usize), Wave>, | 151 | waves: HashMap<(PathBuf, usize), Wave>, |
| 152 | + /// What each source's stand-in is up to ([`engine::proxy`]), filled like | ||
| 153 | + /// `waves`: presence means "asked", so the encode is started once per file | ||
| 154 | + /// however many times the library is drawn. The switch that decides whether | ||
| 155 | + /// they are *played* is the session's own -- it is the project's and is | ||
| 156 | + /// saved with it, where this map is this window's view of the cache. | ||
| 157 | + proxies: HashMap<PathBuf, Proxy>, | ||
| 152 | /// Which audio streams each imported file has, as its header describes | 158 | /// Which audio streams each imported file has, as its header describes |
| 153 | /// them: one library row per entry. Keyed and filled like `waves` -- | 159 | /// them: one library row per entry. Keyed and filled like `waves` -- |
| 154 | /// presence means "asked" -- and an empty list is a silent file, which is | 160 | /// presence means "asked" -- and an empty list is a silent file, which is |
| @@ -602,6 +608,7 @@ fn main() { | |||
| 602 | selected_asset: None, | 608 | selected_asset: None, |
| 603 | library_tab: LibraryTab::Media, | 609 | library_tab: LibraryTab::Media, |
| 604 | waves: HashMap::new(), | 610 | waves: HashMap::new(), |
| 611 | + proxies: HashMap::new(), | ||
| 605 | streams: HashMap::new(), | 612 | streams: HashMap::new(), |
| 606 | bitrates: HashMap::new(), | 613 | bitrates: HashMap::new(), |
| 607 | sizes: HashMap::new(), | 614 | sizes: HashMap::new(), |
crates/app/src/player/actions.rsmodified+1 -0
| @@ -87,6 +87,7 @@ impl Player { | |||
| 87 | ActionId::Mix => self.open_mix(None, cx), | 87 | ActionId::Mix => self.open_mix(None, cx), |
| 88 | ActionId::ToggleSnap => self.toggle_snap(cx), | 88 | ActionId::ToggleSnap => self.toggle_snap(cx), |
| 89 | ActionId::ToggleSubtitles => self.toggle_subtitles(cx), | 89 | ActionId::ToggleSubtitles => self.toggle_subtitles(cx), |
| 90 | + ActionId::ToggleProxies => self.toggle_proxies(cx), | ||
| 90 | // The keyboard's door to the same list the toolbar button opens. | 91 | // The keyboard's door to the same list the toolbar button opens. |
| 91 | // At the window's corner, since a stroke names no place -- and | 92 | // At the window's corner, since a stroke names no place -- and |
| 92 | // [`menu_at`] keeps it on screen from there. | 93 | // [`menu_at`] keeps it on screen from there. |
crates/app/src/player/export.rsmodified+45 -0
| @@ -111,6 +111,51 @@ impl Player { | |||
| 111 | }) | 111 | }) |
| 112 | .detach(); | 112 | .detach(); |
| 113 | } | 113 | } |
| 114 | + // A stand-in for every film this machine cannot cut at speed, started | ||
| 115 | + // the moment the file arrives and made while the editor keeps running | ||
| 116 | + // ([`engine::proxy`]). Off the render thread for the reason the sync | ||
| 117 | + // walk above is -- the decision reads the same header -- and the encode | ||
| 118 | + // itself is the engine's own worker, so what comes back here is a | ||
| 119 | + // handle to poll and not a wait. | ||
| 120 | + for path in unseen_paths(session.sources(), &self.proxies) { | ||
| 121 | + // Two at a time, and the rest at the next repaint: a stand-in is a | ||
| 122 | + // whole film re-encoded, and a library of ten dropped at once would | ||
| 123 | + // otherwise start ten encodes fighting over the one hardware seat. | ||
| 124 | + // The unstarted ones simply stay out of the map, which is what | ||
| 125 | + // brings them back here ([`unseen_paths`]). | ||
| 126 | + if self.in_flight_proxies() >= PROXIES_AT_ONCE { | ||
| 127 | + break; | ||
| 128 | + } | ||
| 129 | + self.proxies.insert(path.clone(), Proxy::Asked); | ||
| 130 | + let started = cx.background_executor().spawn({ | ||
| 131 | + let path = path.clone(); | ||
| 132 | + async move { engine::proxy::generate_if_wanted(&path) } | ||
| 133 | + }); | ||
| 134 | + cx.spawn(async move |this, cx| { | ||
| 135 | + let started = started.await; | ||
| 136 | + this.update(cx, |this, cx| { | ||
| 137 | + let state = match started { | ||
| 138 | + Ok(Some(job)) => Proxy::Making(job), | ||
| 139 | + // A film that needs none keeps the state it was | ||
| 140 | + // inserted with, which is what it is. | ||
| 141 | + Ok(None) => Proxy::Native, | ||
| 142 | + Err(e) => { | ||
| 143 | + let text = format!( | ||
| 144 | + "NO PROXY for {} — {e} — the film itself is what plays", | ||
| 145 | + file_name(&path) | ||
| 146 | + ); | ||
| 147 | + eprintln!("{text}"); | ||
| 148 | + this.notify_user(text.into()); | ||
| 149 | + Proxy::Failed | ||
| 150 | + } | ||
| 151 | + }; | ||
| 152 | + this.proxies.insert(path, state); | ||
| 153 | + cx.notify(); | ||
| 154 | + }) | ||
| 155 | + .ok(); | ||
| 156 | + }) | ||
| 157 | + .detach(); | ||
| 158 | + } | ||
| 114 | for key in unseen_sources(session.sources(), &self.waves) { | 159 | for key in unseen_sources(session.sources(), &self.waves) { |
| 115 | self.waves.insert(key.clone(), Wave::Loading); | 160 | self.waves.insert(key.clone(), Wave::Loading); |
| 116 | let decoded = cx.background_executor().spawn({ | 161 | let decoded = cx.background_executor().spawn({ |
crates/app/src/player/library.rsmodified+111 -0
| @@ -296,6 +296,117 @@ impl Player { | |||
| 296 | /// ...and starts whatever is queued behind it, which is the one place the | 296 | /// ...and starts whatever is queued behind it, which is the one place the |
| 297 | /// files argv named can begin: they are put in the queue before there is a | 297 | /// files argv named can begin: they are put in the queue before there is a |
| 298 | /// context to spawn a worker from. | 298 | /// context to spawn a worker from. |
| 299 | + /// Takes each finished stand-in's verdict, once. Sampled here rather than | ||
| 300 | + /// while drawing, for [`Player::poll_export`]'s reason -- and it is the one | ||
| 301 | + /// place a proxy job's outcome is read, so "ready" on a row and the file in | ||
| 302 | + /// the cache are the same fact. | ||
| 303 | + /// | ||
| 304 | + /// Nothing waits for it: until a proxy is ready the film itself is what | ||
| 305 | + /// plays, switch or no switch ([`engine::PlaybackSession::picture_path`]), | ||
| 306 | + /// so a failure costs a line and no more. | ||
| 307 | + pub(crate) fn poll_proxies(&mut self, cx: &mut Context<Self>) { | ||
| 308 | + let done: Vec<(PathBuf, engine::Result<PathBuf>)> = self | ||
| 309 | + .proxies | ||
| 310 | + .iter() | ||
| 311 | + .filter_map(|(path, state)| match state { | ||
| 312 | + Proxy::Making(job) => Some((path.clone(), job.outcome()?)), | ||
| 313 | + _ => None, | ||
| 314 | + }) | ||
| 315 | + .collect(); | ||
| 316 | + for (path, outcome) in done { | ||
| 317 | + let text = match &outcome { | ||
| 318 | + Ok(_) => format!( | ||
| 319 | + "PROXY READY for {} — Proxies on cuts on it", | ||
| 320 | + file_name(&path) | ||
| 321 | + ), | ||
| 322 | + Err(e) => format!( | ||
| 323 | + "PROXY FAILED for {} — {e} — the film itself is what plays", | ||
| 324 | + file_name(&path) | ||
| 325 | + ), | ||
| 326 | + }; | ||
| 327 | + eprintln!("{text}"); | ||
| 328 | + self.notify_user(text.into()); | ||
| 329 | + let state = match outcome { | ||
| 330 | + Ok(_) => Proxy::Ready, | ||
| 331 | + Err(_) => Proxy::Failed, | ||
| 332 | + }; | ||
| 333 | + self.proxies.insert(path, state); | ||
| 334 | + cx.notify(); | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + /// What the Proxies button says after the state: how far the stand-ins | ||
| 339 | + /// have got, since "on" with nothing made yet and "on" with the whole | ||
| 340 | + /// library standing in are two different things to be looking at. Empty | ||
| 341 | + /// where no film here wants one, which is the ordinary case. | ||
| 342 | + pub(crate) fn proxy_tail(&self) -> String { | ||
| 343 | + let making = self.proxies.values().filter_map(|p| match p { | ||
| 344 | + Proxy::Making(job) => Some(job.progress()), | ||
| 345 | + _ => None, | ||
| 346 | + }); | ||
| 347 | + // The one furthest along would read as done while three others sit at | ||
| 348 | + // nothing: the *least* finished is what the button reports. | ||
| 349 | + match making.fold(f32::INFINITY, f32::min) { | ||
| 350 | + least if least.is_finite() => format!(" · {}%", (least * 100.) as u32), | ||
| 351 | + _ => String::new(), | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + /// Whether any stand-in is still being made -- what keeps the frame loop | ||
| 356 | + /// alive while one is, so its percentage moves on screen. | ||
| 357 | + pub(crate) fn making_proxies(&self) -> bool { | ||
| 358 | + self.proxies | ||
| 359 | + .values() | ||
| 360 | + .any(|p| matches!(p, Proxy::Making(_))) | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + /// How many films are between "shall we?" and "done": the number the start | ||
| 364 | + /// of another is held against ([`PROXIES_AT_ONCE`]). A header being read | ||
| 365 | + /// counts, because the answer may be an encode. | ||
| 366 | + pub(crate) fn in_flight_proxies(&self) -> usize { | ||
| 367 | + self.proxies | ||
| 368 | + .values() | ||
| 369 | + .filter(|p| matches!(p, Proxy::Asked | Proxy::Making(_))) | ||
| 370 | + .count() | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + /// Cuts on the stand-ins, or on the films themselves. The picture and only | ||
| 374 | + /// the picture: the sound is the film's either way, and so is every frame | ||
| 375 | + /// an export writes. | ||
| 376 | + pub(crate) fn toggle_proxies(&mut self, cx: &mut Context<Self>) { | ||
| 377 | + let Some(session) = &mut self.session else { | ||
| 378 | + return; | ||
| 379 | + }; | ||
| 380 | + let on = !session.proxies(); | ||
| 381 | + session.set_proxies(on); | ||
| 382 | + // What is really under the switch, said in the same breath: a project | ||
| 383 | + // whose films have no stand-in yet would otherwise read as a switch | ||
| 384 | + // that does nothing. | ||
| 385 | + let ready = self | ||
| 386 | + .proxies | ||
| 387 | + .values() | ||
| 388 | + .filter(|p| matches!(p, Proxy::Ready)) | ||
| 389 | + .count(); | ||
| 390 | + let making = self | ||
| 391 | + .proxies | ||
| 392 | + .values() | ||
| 393 | + .filter(|p| matches!(p, Proxy::Making(_))) | ||
| 394 | + .count(); | ||
| 395 | + let text = match (on, ready, making) { | ||
| 396 | + (false, ..) => "PROXIES OFF — the films themselves are what play".to_string(), | ||
| 397 | + (true, 0, 0) => { | ||
| 398 | + "PROXIES ON — no film here has one, so the films themselves play".to_string() | ||
| 399 | + } | ||
| 400 | + (true, 0, n) => format!("PROXIES ON — {n} still being made; the films play until then"), | ||
| 401 | + (true, n, 0) => format!("PROXIES ON — cutting on {n}"), | ||
| 402 | + (true, n, m) => format!("PROXIES ON — cutting on {n}, {m} still being made"), | ||
| 403 | + }; | ||
| 404 | + eprintln!("{text}"); | ||
| 405 | + self.notify_user(text.into()); | ||
| 406 | + self.reset_after_reseek(); | ||
| 407 | + cx.notify(); | ||
| 408 | + } | ||
| 409 | + | ||
| 299 | pub(crate) fn poll_import(&mut self, cx: &mut Context<Self>) { | 410 | pub(crate) fn poll_import(&mut self, cx: &mut Context<Self>) { |
| 300 | match &mut self.importing { | 411 | match &mut self.importing { |
| 301 | Some(import) => { | 412 | Some(import) => { |
crates/app/src/render.rsmodified+5 -0
| @@ -23,6 +23,7 @@ impl Render for Player { | |||
| 23 | self.poll_export(); | 23 | self.poll_export(); |
| 24 | self.poll_import(cx); | 24 | self.poll_import(cx); |
| 25 | self.poll_silence(); | 25 | self.poll_silence(); |
| 26 | + self.poll_proxies(cx); | ||
| 26 | // Every way a source can arrive -- argv, an import, a project load -- | 27 | // Every way a source can arrive -- argv, an import, a project load -- |
| 27 | // has been through a repaint by the time its clips are drawn, so this | 28 | // has been through a repaint by the time its clips are drawn, so this |
| 28 | // is the one place that has to notice a new one. | 29 | // is the one place that has to notice a new one. |
| @@ -57,6 +58,10 @@ impl Render for Player { | |||
| 57 | // the screen on a repaint, and a still line is the very thing this | 58 | // the screen on a repaint, and a still line is the very thing this |
| 58 | // card was rewritten to disprove. | 59 | // card was rewritten to disprove. |
| 59 | || self.silence_scan.is_some() | 60 | || self.silence_scan.is_some() |
| 61 | + // ...and a stand-in being made: its percentage on the library row | ||
| 62 | + // only reaches the screen on a repaint, and a bar that never moves | ||
| 63 | + // is exactly what a person reads as a hung encode. | ||
| 64 | + || self.making_proxies() | ||
| 60 | { | 65 | { |
| 61 | window.request_animation_frame(); | 66 | window.request_animation_frame(); |
| 62 | } | 67 | } |
crates/app/src/ui/inspector.rsmodified+18 -0
| @@ -284,6 +284,24 @@ impl Player { | |||
| 284 | this.open_picker(Pick::Tone, event.position(), cx) | 284 | this.open_picker(Pick::Tone, event.position(), cx) |
| 285 | }), | 285 | }), |
| 286 | )) | 286 | )) |
| 287 | + // Its own rect and a label that *is* the state, the rule | ||
| 288 | + // the snap toggle writes down: a button that resized itself | ||
| 289 | + // on every press made the row shuffle under the pointer. | ||
| 290 | + .child(self.action_control( | ||
| 291 | + "proxies", | ||
| 292 | + TONE_SLOT_W, | ||
| 293 | + BG_RAISED(), | ||
| 294 | + None, | ||
| 295 | + match self.session.as_ref().map(PlaybackSession::proxies) { | ||
| 296 | + Some(true) => format!("Proxies on{}", self.proxy_tail()), | ||
| 297 | + Some(false) => format!("Proxies off{}", self.proxy_tail()), | ||
| 298 | + None => "Proxies".to_string(), | ||
| 299 | + }, | ||
| 300 | + "cuts on small stand-ins of the big films; the sound and every export \ | ||
| 301 | + stay the film's own", | ||
| 302 | + ActionId::ToggleProxies, | ||
| 303 | + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)), | ||
| 304 | + )) | ||
| 287 | .child(self.action_control( | 305 | .child(self.action_control( |
| 288 | "inspect-mix", | 306 | "inspect-mix", |
| 289 | 0., | 307 | 0., |
crates/app/src/ui/library.rsmodified+10 -0
| @@ -112,6 +112,16 @@ impl Player { | |||
| 112 | &timecode(f64::from(row.frames) / self.fps, self.fps), | 112 | &timecode(f64::from(row.frames) / self.fps, self.fps), |
| 113 | ), | 113 | ), |
| 114 | }; | 114 | }; |
| 115 | + // ...and what this file's stand-in is up to, after its length: a | ||
| 116 | + // percentage while one is being made, the word while there is one, | ||
| 117 | + // and nothing at all for a film that wants none ([`Proxy::detail`]). | ||
| 118 | + let under = join_detail( | ||
| 119 | + &under, | ||
| 120 | + &self | ||
| 121 | + .proxies | ||
| 122 | + .get(&row.path) | ||
| 123 | + .map_or_else(String::new, Proxy::detail), | ||
| 124 | + ); | ||
| 115 | let usable = row.unusable.is_none(); | 125 | let usable = row.unusable.is_none(); |
| 116 | let (path, stream) = (row.path.clone(), row.stream); | 126 | let (path, stream) = (row.path.clone(), row.stream); |
| 117 | let dragged = (path.clone(), stream); | 127 | let dragged = (path.clone(), stream); |
crates/engine/src/proxy.rsmodified+30 -3
| @@ -178,18 +178,45 @@ impl Job { | |||
| 178 | /// back through [`Job::outcome`], so a caller has two places to look and not | 178 | /// back through [`Job::outcome`], so a caller has two places to look and not |
| 179 | /// twenty. | 179 | /// twenty. |
| 180 | pub fn generate(source: &Path) -> crate::Result<Job> { | 180 | pub fn generate(source: &Path) -> crate::Result<Job> { |
| 181 | + Ok(started(source, |_| true)?.expect("nothing was filtered out")) | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +/// The same, for a file that is worth standing in for and nobody else | ||
| 185 | +/// ([`wanted`]) -- `Ok(None)` is a film this machine already cuts at speed. | ||
| 186 | +/// | ||
| 187 | +/// The header is read *once* for both questions: on a Matroska that read is the | ||
| 188 | +/// cluster walk, so asking `wanted` and then `generate` separately would pay | ||
| 189 | +/// for it twice. | ||
| 190 | +pub fn generate_if_wanted(source: &Path) -> crate::Result<Option<Job>> { | ||
| 191 | + started(source, wanted) | ||
| 192 | +} | ||
| 193 | + | ||
| 194 | +/// Both doors: the cache is looked at, the header is read once, and `only_if` | ||
| 195 | +/// decides off that header whether there is anything to do. | ||
| 196 | +fn started(source: &Path, only_if: fn(&VideoMeta) -> bool) -> crate::Result<Option<Job>> { | ||
| 181 | let out = path_for(source).ok_or("no cache directory to keep a proxy in")?; | 197 | let out = path_for(source).ok_or("no cache directory to keep a proxy in")?; |
| 182 | if out.is_file() { | 198 | if out.is_file() { |
| 183 | - return Ok(Job { out, handle: None }); | 199 | + return Ok(Some(Job { out, handle: None })); |
| 184 | } | 200 | } |
| 185 | // The source's own header: its rate and length are the proxy's (a stand-in | 201 | // The source's own header: its rate and length are the proxy's (a stand-in |
| 186 | // that ran at another rate or stopped early would put every cut on another | 202 | // that ran at another rate or stopped early would put every cut on another |
| 187 | // frame), and only its picture size changes. | 203 | // frame), and only its picture size changes. |
| 188 | let (meta, _) = Demuxer::open(source)?; | 204 | let (meta, _) = Demuxer::open(source)?; |
| 205 | + if !only_if(&meta) { | ||
| 206 | + return Ok(None); | ||
| 207 | + } | ||
| 189 | let (width, height) = size_for(&meta); | 208 | let (width, height) = size_for(&meta); |
| 190 | if let Some(dir) = out.parent() { | 209 | if let Some(dir) = out.parent() { |
| 191 | std::fs::create_dir_all(dir)?; | 210 | std::fs::create_dir_all(dir)?; |
| 192 | } | 211 | } |
| 212 | + // What a killed editor left behind: the export worker deletes its own part | ||
| 213 | + // file when it is cancelled or fails, but nothing can delete it for a | ||
| 214 | + // process that was killed -- and a proxy of a feature film is hundreds of | ||
| 215 | + // megabytes of cache nothing would ever look at again. The key is the same, | ||
| 216 | + // so this is that same film's own leftover and not somebody else's. | ||
| 217 | + let mut part = out.clone().into_os_string(); | ||
| 218 | + part.push(".part"); | ||
| 219 | + let _ = std::fs::remove_file(PathBuf::from(part)); | ||
| 193 | // One video lane, one clip, the whole file -- and *no* audio lane, which is | 220 | // One video lane, one clip, the whole file -- and *no* audio lane, which is |
| 194 | // what makes the proxy picture-only: the export walk codes the lanes it is | 221 | // what makes the proxy picture-only: the export walk codes the lanes it is |
| 195 | // given and there is no sound among them. | 222 | // given and there is no sound among them. |
| @@ -232,10 +259,10 @@ pub fn generate(source: &Path) -> crate::Result<Job> { | |||
| 232 | ..Default::default() | 259 | ..Default::default() |
| 233 | }, | 260 | }, |
| 234 | ); | 261 | ); |
| 235 | - Ok(Job { | 262 | + Ok(Some(Job { |
| 236 | out, | 263 | out, |
| 237 | handle: Some(handle), | 264 | handle: Some(handle), |
| 238 | - }) | 265 | + })) |
| 239 | } | 266 | } |
| 240 | 267 | ||
| 241 | #[cfg(test)] | 268 | #[cfg(test)] |