app: download ffmpeg on the first run, not the first export
record-daemon / Build, check and test (push) Failing after 1m15s
record-daemon / Build, check and test (push) Failing after 1m15s
Clip export needs ffmpeg, and the app fetched it when an export was asked for: a minute of nothing at the worst moment, with the export sitting behind it. The run that follows an install now fetches it in the background and narrates the download in the notice banner; the notice is updated in place and leaves another notice alone. A hidden start (the login item) skips the fetch and leaves it to the export. Only ffmpeg.exe is unpacked. The archive also carries ffplay and ffprobe, which the export paths never call: unpacking all three put 370 MB beside the exe instead of 105 MB. An export asked for while the download runs says so instead of starting a second download over the same directory, and --fetch-ffmpeg runs the same fetch from a shell, printing progress. Checked on this machine: --fetch-ffmpeg downloaded in about 20 s, unpacked, and answered "ready"; a second run returned at once.
This commit is contained in:
1 parent
20303d5ddc
commit
297118cfc1
4 files changed
+174
-5
No files matched your search
@@ -7,6 +7,7 @@ use std::time::Duration;
|
||||
use rune::tok::type_;
|
||||
use rune::{Cx, El, Key, KeyEvent, Tx, col, el, row, text};
|
||||
|
||||
use crate::export;
|
||||
use crate::history::{self, QueueCategory, Summary, Timeline};
|
||||
use crate::ipc::{self, Daemon};
|
||||
use crate::os;
|
||||
@@ -145,6 +146,9 @@ pub struct App {
|
||||
pub highlights_scroll: ui::ScrollBar,
|
||||
pub events_scroll: ui::ScrollBar,
|
||||
pub notice: Option<Notice>,
|
||||
/// ffmpeg being downloaded on the first run, and the whole percent it last reported.
|
||||
pub ffmpeg_rx: Option<Receiver<export::FetchEvent>>,
|
||||
pub ffmpeg_pct: Option<u64>,
|
||||
pub autostart: bool,
|
||||
pub logs: String,
|
||||
pub pending_review: bool,
|
||||
@@ -189,6 +193,8 @@ impl App {
|
||||
highlights_scroll: ui::ScrollBar::new(),
|
||||
events_scroll: ui::ScrollBar::new(),
|
||||
notice: None,
|
||||
ffmpeg_rx: None,
|
||||
ffmpeg_pct: None,
|
||||
autostart,
|
||||
logs: String::new(),
|
||||
pending_review: false,
|
||||
@@ -201,6 +207,19 @@ impl App {
|
||||
if headless && !live {
|
||||
app.demo();
|
||||
}
|
||||
// Clip export runs on ffmpeg. Fetch it now, on the run that follows an install, so the
|
||||
// first export does not sit behind a download. A hidden start (the login item) leaves it
|
||||
// to the export itself.
|
||||
let hidden = std::env::args().any(|arg| arg == "--hidden");
|
||||
if !headless && !hidden && export::missing() && !export::fetching() {
|
||||
let (tx, rx) = channel();
|
||||
std::thread::spawn(move || {
|
||||
let _ = export::fetch(move |event| {
|
||||
let _ = tx.send(event);
|
||||
});
|
||||
});
|
||||
app.ffmpeg_rx = Some(rx);
|
||||
}
|
||||
app
|
||||
}
|
||||
|
||||
@@ -299,6 +318,15 @@ impl App {
|
||||
});
|
||||
}
|
||||
|
||||
/// Whether the notice on screen belongs to the download. It is updated in place; a notice
|
||||
/// the app is showing for something else is not replaced by the progress.
|
||||
fn ffmpeg_banner_showing(&self) -> bool {
|
||||
match &self.notice {
|
||||
None => true,
|
||||
Some(notice) => notice.text.starts_with("Downloading ffmpeg"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_settings(&self) {
|
||||
self.daemon.get_settings();
|
||||
}
|
||||
@@ -661,6 +689,44 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
// Taken out of the field so the notice helpers below can borrow the app.
|
||||
if let Some(rx) = self.ffmpeg_rx.take() {
|
||||
let mut finished = false;
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
match event {
|
||||
export::FetchEvent::Bytes { done, total } => {
|
||||
let pct = if total > 0 { done * 100 / total } else { 0 };
|
||||
if self.ffmpeg_pct != Some(pct) {
|
||||
self.ffmpeg_pct = Some(pct);
|
||||
if self.ffmpeg_banner_showing() {
|
||||
self.notify(format!("Downloading ffmpeg for clip exports: {pct}%"));
|
||||
}
|
||||
}
|
||||
}
|
||||
export::FetchEvent::Unpacking => {
|
||||
if self.ffmpeg_banner_showing() {
|
||||
self.notify("Unpacking ffmpeg…");
|
||||
}
|
||||
}
|
||||
export::FetchEvent::Finished(result) => {
|
||||
finished = true;
|
||||
match result {
|
||||
Ok(()) => {
|
||||
if self.ffmpeg_banner_showing() {
|
||||
self.notify("ffmpeg is ready: clip export works now");
|
||||
}
|
||||
}
|
||||
Err(e) => self.notify_error(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
if !finished {
|
||||
self.ffmpeg_rx = Some(rx);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(rx) = &self.review_rx {
|
||||
match rx.try_recv() {
|
||||
Ok(None) => {
|
||||
|
||||
Reference in new issue
Block a user