progression
parent
f3b960c2f5
commit
49d811fc65
|
|
@ -89,6 +89,12 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
|
|
@ -696,6 +702,10 @@ dependencies = [
|
|||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lib"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.151"
|
||||
|
|
@ -1065,8 +1075,10 @@ dependencies = [
|
|||
name = "src"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dioxus",
|
||||
"dioxus-web",
|
||||
"lib",
|
||||
"rfd",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ edition = "2021"
|
|||
dioxus = "0.4.3"
|
||||
dioxus-web = "0.4.3"
|
||||
rfd = "0.12.1"
|
||||
lib = { path = "../src-lib" }
|
||||
base64 = "0.21.5"
|
||||
#dioxus-desktop = "0.4.3"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
|
||||
use dioxus::prelude::*;
|
||||
use rfd::AsyncFileDialog;
|
||||
use lib;
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
|
||||
fn main() {
|
||||
// launch the dioxus app in a webview
|
||||
|
|
@ -12,6 +14,7 @@ fn main() {
|
|||
// define a component that renders a div with the text "Hello, world!"
|
||||
fn App(cx: Scope) -> Element {
|
||||
let file = use_state(cx, String::new);
|
||||
let analysis = use_state(cx, Vec::<Analyzed>::new);
|
||||
cx.render(rsx! {
|
||||
header {
|
||||
h1 { "home-video-blue-extractinator" }
|
||||
|
|
@ -38,18 +41,70 @@ fn App(cx: Scope) -> Element {
|
|||
p { file.get().clone() }
|
||||
}
|
||||
div {
|
||||
input { r#type: "button", value: "analyze", onclick: move |evt| { analyze(evt); } }
|
||||
input { r#type: "button", value: "clipify", onclick: move |evt| { clipify(evt); } }
|
||||
input { r#type: "button", value: "analyze", onclick: move |evt| {
|
||||
to_owned![file];
|
||||
to_owned![analysis];
|
||||
async move {
|
||||
analysis.set(analyze(file.get().clone()));
|
||||
}
|
||||
}}
|
||||
input { r#type: "button", value: "clipify", onclick: move |evt| { clipify(file.get().clone()); } }
|
||||
}
|
||||
div {
|
||||
analysis.get().iter().map(|a| {
|
||||
rsx! {
|
||||
p {
|
||||
"{a.start}..{a.stop}: "
|
||||
img { src: "data:image/png;base64, {a.screenshot}" }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn analyze(evt: Event<MouseData>) {
|
||||
eprintln!("analyze");
|
||||
struct Analyzed {
|
||||
start: String,
|
||||
stop: String,
|
||||
screenshot: String,
|
||||
}
|
||||
|
||||
fn clipify(evt: Event<MouseData>) {
|
||||
fn analyze(file: String) -> Vec<Analyzed> {
|
||||
//let content_spans = lib::video::inspect(&file); // TODO
|
||||
let content_spans: Result<Vec<lib::video::ContentSpan>, String> = Ok(vec![lib::video::ContentSpan{start: 0.5, stop: 20.2}]);
|
||||
if content_spans.is_err() {
|
||||
return vec![Analyzed{
|
||||
start: format!("<<err analyzing {}", file),
|
||||
stop: format!("{}>>", content_spans.err().unwrap()),
|
||||
screenshot: a_png.to_string(),
|
||||
}];
|
||||
}
|
||||
let head: Vec<lib::video::ContentSpan> = vec![lib::video::ContentSpan{start: 0.0, stop: 0.0}];
|
||||
let content_spans = content_spans.unwrap();
|
||||
head.iter().chain(content_spans.iter())
|
||||
.map(|content_span| {
|
||||
eprintln!("analyze");
|
||||
let mut result = Analyzed{
|
||||
start: content_span.start.to_string(),
|
||||
stop: content_span.stop.to_string(),
|
||||
screenshot: a_png.to_string(),
|
||||
};
|
||||
match lib::video::screenshot_png(
|
||||
&file,
|
||||
content_span.start,
|
||||
) {
|
||||
Ok(png) => { result.screenshot = general_purpose::STANDARD.encode(&png); },
|
||||
Err(msg) => { result.stop = format!("{} <<failed to screenshot {}: {}>>", result.stop, file, msg); },
|
||||
};
|
||||
result
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn clipify(file: String) {
|
||||
eprintln!("clipify");
|
||||
}
|
||||
|
||||
const a_png: &str = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
|
||||
|
|
|
|||
Loading…
Reference in New Issue