4 Commits
0.1.2 ... 0.1.3

Author SHA1 Message Date
Bel LaPointe
10ef89f0e9 dx bundle --release --platform x86_64-apple-darwin 2023-12-28 21:33:03 -05:00
Bel LaPointe
32a652519a statuses per-event because scrolling stinks 2023-12-28 21:20:27 -05:00
Bel LaPointe
a8ba8fc97d drop todos since web so far gone 2023-12-28 21:12:47 -05:00
Bel LaPointe
5bd118704d style.css and numbered instructions 2023-12-28 21:12:26 -05:00
5 changed files with 93 additions and 61 deletions

22
src/Cargo.lock generated
View File

@@ -1349,6 +1349,17 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "home-video-blue-extractinator"
version = "0.1.0"
dependencies = [
"base64 0.21.5",
"dioxus",
"dioxus-desktop",
"lib",
"opener",
]
[[package]] [[package]]
name = "html5ever" name = "html5ever"
version = "0.25.2" version = "0.25.2"
@@ -2570,17 +2581,6 @@ dependencies = [
"lock_api", "lock_api",
] ]
[[package]]
name = "src"
version = "0.1.0"
dependencies = [
"base64 0.21.5",
"dioxus",
"dioxus-desktop",
"lib",
"opener",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.0" version = "1.2.0"

View File

@@ -1,5 +1,5 @@
[package] [package]
name = "src" name = "home-video-blue-extractinator"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
@@ -10,5 +10,13 @@ dioxus = "0.4.3"
lib = { path = "../src-lib" } lib = { path = "../src-lib" }
base64 = "0.21.5" base64 = "0.21.5"
opener = "0.6.1" opener = "0.6.1"
#dioxus-web = "0.4.3"
dioxus-desktop = "0.4.3" dioxus-desktop = "0.4.3"
[package.metadata.bundle]
name = "home-video-blue-extractinator"
identifier = "com.breel.home-video-blue-extractinator"
version = "0.1.0"
copyright = "Copyright (c) breel.dev 2023. All rights reserved."
long_description = """
Tool to turn long home movies into clips with less noise.
"""

12
src/Dioxus.toml Normal file
View File

@@ -0,0 +1,12 @@
[application]
name = "home-video-blue-extractinator"
default_platform = "desktop"
[web.app]
title = "home-video-blue-extractinator"
[web.watcher]
[web.resource]
[web.resource.dev]

View File

@@ -8,39 +8,30 @@ use core::cmp::Ordering;
use std::str::FromStr; use std::str::FromStr;
fn main() { fn main() {
// launch the dioxus app in a webview dioxus_desktop::launch(App);
dioxus_desktop::launch(App); // TODO desktop
//dioxus_web::launch(App);
} }
// define a component that renders a div with the text "Hello, world!" // define a component that renders a div with the text "Hello, world!"
fn App(cx: Scope) -> Element { fn App(cx: Scope) -> Element {
let file = use_state(cx, || String::new()); let file = use_state(cx, || String::new());
let status = use_state(cx, || String::new()); let analyze_status = use_state(cx, || String::new());
let clipify_status = use_state(cx, || String::new());
let processing = use_state(cx, || false);
let analysis = use_state(cx, || Analysis::new()); let analysis = use_state(cx, || Analysis::new());
let a_css = String::from_utf8_lossy(include_bytes!("./style.css"));
cx.render(rsx! { cx.render(rsx! {
header { header {
style { " title { "home-video-blue-extractinator" }
body {{ style { "{a_css}" }
max-width: 600pt;
margin: auto;
zoom: 150%;
}}
label {{
display: block;
}}
label:has(input[type=checkbox]:checked) {{
background-color: lightgreen;
}}
" }
} }
main { main {
rsx! { rsx! {
h1 { "home-video-blue-extractinator" } h1 { "home-video-blue-extractinator" }
h3 { "1. Choose your movie" }
div { div {
input { input {
r#type: "file", r#type: "file",
disabled: status.get().starts_with("[WORKING]"), disabled: *processing.get(),
onchange: |evt| { onchange: |evt| {
to_owned![file]; to_owned![file];
if let Some(file_engine) = &evt.files { if let Some(file_engine) = &evt.files {
@@ -52,37 +43,37 @@ fn App(cx: Scope) -> Element {
}, },
p { file.get().clone() } p { file.get().clone() }
} }
h3 { "2. Analyze your movie" }
div { div {
input { r#type: "button", value: "analyze", disabled: file.get().len() == 0 || status.get().starts_with("[WORKING]"), onclick: move |_| { input { r#type: "button", value: "analyze", disabled: file.get().len() == 0 || *processing.get(), onclick: move |_| {
cx.spawn({ cx.spawn({
let file = file.to_owned(); let file = file.to_owned();
let status = status.to_owned(); let analyze_status = analyze_status.to_owned();
let processing = processing.to_owned();
let analysis = analysis.to_owned(); let analysis = analysis.to_owned();
async move { async move {
status.set(format!("[WORKING] analyzing {file}... (this may take a while, like 5 minutes, but I promise I'm working on it)")); processing.set(true);
analyze_status.set(format!("analyzing {file}... (this may take a while, like 5 minutes, but I promise I'm working on it)"));
let analyzed = analyze(file.get().clone()).await; let analyzed = analyze(file.get().clone()).await;
if analyzed.err.len() > 0 { if analyzed.err.len() > 0 {
status.set(analyzed.err.clone()); analyze_status.set(analyzed.err.clone());
} else { } else {
status.set(format!( analyze_status.set(format!(
"found {} clips to keep and {} clips to drop", "found {} clips to keep and {} clips to drop",
analyzed.result.iter().filter(|x| x.has_content).count(), analyzed.result.iter().filter(|x| x.has_content).count(),
analyzed.result.iter().filter(|x| !x.has_content).count(), analyzed.result.iter().filter(|x| !x.has_content).count(),
)); ));
} }
analysis.set(analyzed); analysis.set(analyzed);
processing.set(false);
} }
}); });
}} }}
br {}
div { analyze_status.get().clone() }
} }
div { div {
br {}
status.get().clone()
br {}
}
div {
h3 { "Content Spans" }
form { form {
onsubmit: |evt| { onsubmit: |evt| {
let content_spans: Vec<_> = evt.values.iter() let content_spans: Vec<_> = evt.values.iter()
@@ -96,16 +87,19 @@ fn App(cx: Scope) -> Element {
} }
}) })
.collect(); .collect();
status.set(format!("[WORKING] clipifying {:?}...", content_spans)); clipify_status.set(format!("clipifying {:?}...", content_spans));
let file = file.get().clone(); let file = file.get().clone();
to_owned![status]; to_owned![clipify_status];
to_owned![processing];
async move { async move {
processing.set(true);
let f = clipify(file, content_spans).await; let f = clipify(file, content_spans).await;
status.set(f); clipify_status.set(f);
processing.set(false);
} }
}, },
input { r#type: "submit", value: "clipify selected spans", disabled: file.get().len() == 0 || status.get().starts_with("[WORKING]") || analysis.get().result.len() == 0 }
hr {} hr {}
h3 { "3. Double check the scenes to keep (green) are okay" }
analysis.get().result.iter().map(|a| { analysis.get().result.iter().map(|a| {
rsx! { rsx! {
div { div {
@@ -122,6 +116,11 @@ fn App(cx: Scope) -> Element {
} }
} }
}) })
hr {}
h3 { "4. Submit your re-clip" }
div { clipify_status.get().clone() }
br {}
input { r#type: "submit", value: "clipify selected spans", disabled: file.get().len() == 0 || *processing.get() || analysis.get().result.len() == 0 }
} }
} }
} }
@@ -152,8 +151,7 @@ struct Analyzed {
} }
async fn analyze(file: String) -> Analysis { async fn analyze(file: String) -> Analysis {
let content_spans = lib::video::inspect_async(&file).await; // TODO desktop let content_spans = lib::video::inspect_async(&file).await;
//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() { if content_spans.is_err() {
return Analysis{ return Analysis{
result: vec![], result: vec![],
@@ -208,23 +206,24 @@ async fn analyze(file: String) -> Analysis {
async fn clipify(file: String, content_spans: Vec<lib::video::ContentSpan>) -> String { async fn clipify(file: String, content_spans: Vec<lib::video::ContentSpan>) -> String {
let d = format!("{}.d", &file); let d = format!("{}.d", &file);
let mut last_err = None; let mut statuses = vec![];
for content_span in content_spans.iter() { for content_span in content_spans.iter() {
let output = format!("{}/{}.mp4", &d, content_span.start); let output = format!("{}/{}.mp4", &d, content_span.start);
match std::path::Path::new(&output).exists() {
true => { statuses.push(format!("skipping {} as it already exists", &output)); },
false => {
let cur = lib::video::clip_async(&output, &file, *content_span).await; let cur = lib::video::clip_async(&output, &file, *content_span).await;
if cur.is_err() { if cur.is_err() {
last_err = Some(format!("failed to clipify {} at {}..{}: {}", &file, &content_span.start, &content_span.stop, cur.err().unwrap())); statuses.push(format!("failed to clipify {} at {}..{}: {}", &file, &content_span.start, &content_span.stop, cur.err().unwrap()));
}
}
match last_err {
Some(msg) => msg,
None => {
match opener::open(d.clone()) {
Ok(_) => d,
Err(msg) => format!("failed to open clipify result: {}", msg),
} }
}, },
} }
} }
let _ = opener::open(d.clone());
match statuses.len() {
_ => statuses.join(", "),
0 => d,
}
}
const a_png: &str = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; const a_png: &str = r"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";

13
src/src/style.css Normal file

File diff suppressed because one or more lines are too long