Compare commits

..

No commits in common. "main" and "0.1.3" have entirely different histories.
main ... 0.1.3

5 changed files with 13 additions and 52 deletions

View File

@ -207,14 +207,12 @@ impl Inspection {
for i in 0..unstuck_spans.len() {
let mut span = unstuck_spans[i];
for split in scene_splits.iter() {
if &(span.start + 5.0) < split && split < &(span.stop - 5.0) { // TODO const
if &span.start < split && split < &span.stop { // TODO buffer
result.push(ContentSpan{start: span.start, stop: *split});
span.start = *split;
}
}
if span.stop - span.start > 2.0 {
result.push(span);
}
result.push(span); // TODO assert nontrivial
}
result
}

2
src/Cargo.lock generated
View File

@ -1351,7 +1351,7 @@ dependencies = [
[[package]]
name = "home-video-blue-extractinator"
version = "0.1.6"
version = "0.1.0"
dependencies = [
"base64 0.21.5",
"dioxus",

View File

@ -1,6 +1,6 @@
[package]
name = "home-video-blue-extractinator"
version = "0.1.6"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -15,7 +15,7 @@ dioxus-desktop = "0.4.3"
[package.metadata.bundle]
name = "home-video-blue-extractinator"
identifier = "com.breel.home-video-blue-extractinator"
version = "0.1.6"
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.

View File

@ -1,16 +1,14 @@
#![allow(non_snake_case)]
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
use dioxus::prelude::*;
use dioxus::hooks::use_future;
use lib;
use base64::{engine::general_purpose, Engine as _};
use core::cmp::Ordering;
use std::str::FromStr;
fn main() {
dioxus_desktop::launch(App);
dioxus_desktop::launch_cfg(App, dioxus_desktop::Config::new()
.with_window(dioxus_desktop::WindowBuilder::new()
.with_title("home-video-blue-extractinator")
));
}
// define a component that renders a div with the text "Hello, world!"
@ -20,19 +18,11 @@ fn App(cx: Scope) -> Element {
let clipify_status = use_state(cx, || String::new());
let processing = use_state(cx, || false);
let analysis = use_state(cx, || Analysis::new());
let a_css = String::from_utf8_lossy(include_bytes!("./style.css"));
let processing_css = || {
match *processing.get() {
true => "body { background-color: lightgray !important; opacity: 0.75 !important; }".to_string(),
false => "".to_string(),
}
};
cx.render(rsx! {
header {
title { "home-video-blue-extractinator" }
style { "{a_css} {processing_css()}" }
style { "{a_css}" }
}
main {
rsx! {
@ -43,13 +33,10 @@ fn App(cx: Scope) -> Element {
r#type: "file",
disabled: *processing.get(),
onchange: |evt| {
to_owned![file];
if let Some(file_engine) = &evt.files {
for f in &file_engine.files() {
file.set(f.clone());
analyze_status.set(String::new());
clipify_status.set(String::new());
processing.set(false);
analysis.set(Analysis::new());
}
}
},
@ -122,7 +109,7 @@ fn App(cx: Scope) -> Element {
checked: a.has_content,
name: "{a.start}..{a.stop}",
}
"{a.pretty_range()}"
"{a.start}..{a.stop}: "
br {}
img { src: "data:image/png;base64, {a.screenshot}" }
}
@ -157,33 +144,12 @@ impl Analysis {
#[derive(Clone)]
struct Analyzed {
_start: f32,
_stop: f32,
start: String,
stop: String,
screenshot: String,
has_content: bool,
}
impl Analyzed {
fn pretty_range(&self) -> String {
format!("{} - {}", self.pretty_t(self._start), self.pretty_t(self._stop))
}
fn pretty_t(&self, t: f32) -> String {
if t < 60.0 {
return format!(":{:02}", t as i32);
} else if t < 60.0 * 60.0 {
return format!("{:02}:{:02}", (t / 60.0) as i32, (t % 60.0) as i32);
} else {
return format!("{:02}:{:02}:{:02}",
(t / 60.0 / 60.0) as i32,
(t / 60.0) as i32,
(t % 60.0) as i32);
}
}
}
async fn analyze(file: String) -> Analysis {
let content_spans = lib::video::inspect_async(&file).await;
if content_spans.is_err() {
@ -208,13 +174,11 @@ async fn analyze(file: String) -> Analysis {
let screenshot = |content_span: &lib::video::ContentSpan| -> Analyzed {
let ts = (content_span.start + content_span.stop) / 2.0;
Analyzed {
_start: content_span.start,
_stop: content_span.stop,
start: content_span.start.to_string(),
stop: content_span.stop.to_string(),
screenshot: match lib::video::screenshot_png(&file, ts) {
Ok(png) => general_purpose::STANDARD.encode(&png),
Err(_) => A_PNG.to_string(),
Err(_) => a_png.to_string(),
},
has_content: false,
}
@ -257,9 +221,9 @@ async fn clipify(file: String, content_spans: Vec<lib::video::ContentSpan>) -> S
}
let _ = opener::open(d.clone());
match statuses.len() {
0 => d,
_ => statuses.join(", "),
0 => d,
}
}
const A_PNG: &str = r"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
const a_png: &str = r"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";

File diff suppressed because one or more lines are too long