Compare commits
12 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
6095fd69fc | |
|
|
8f1c0876c5 | |
|
|
6e2cf357f4 | |
|
|
4aede62dbb | |
|
|
c3d6cd1545 | |
|
|
bf7d09dde0 | |
|
|
d13266dd73 | |
|
|
ccc4d7fbd2 | |
|
|
48961fee2a | |
|
|
dfbdba81a6 | |
|
|
a38e39b808 | |
|
|
9e053c96d6 |
|
|
@ -207,12 +207,14 @@ impl Inspection {
|
||||||
for i in 0..unstuck_spans.len() {
|
for i in 0..unstuck_spans.len() {
|
||||||
let mut span = unstuck_spans[i];
|
let mut span = unstuck_spans[i];
|
||||||
for split in scene_splits.iter() {
|
for split in scene_splits.iter() {
|
||||||
if &span.start < split && split < &span.stop { // TODO buffer
|
if &(span.start + 5.0) < split && split < &(span.stop - 5.0) { // TODO const
|
||||||
result.push(ContentSpan{start: span.start, stop: *split});
|
result.push(ContentSpan{start: span.start, stop: *split});
|
||||||
span.start = *split;
|
span.start = *split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.push(span); // TODO assert nontrivial
|
if span.stop - span.start > 2.0 {
|
||||||
|
result.push(span);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1351,7 +1351,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "home-video-blue-extractinator"
|
name = "home-video-blue-extractinator"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.21.5",
|
"base64 0.21.5",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "home-video-blue-extractinator"
|
name = "home-video-blue-extractinator"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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]
|
[package.metadata.bundle]
|
||||||
name = "home-video-blue-extractinator"
|
name = "home-video-blue-extractinator"
|
||||||
identifier = "com.breel.home-video-blue-extractinator"
|
identifier = "com.breel.home-video-blue-extractinator"
|
||||||
version = "0.1.0"
|
version = "0.1.6"
|
||||||
copyright = "Copyright (c) breel.dev 2023. All rights reserved."
|
copyright = "Copyright (c) breel.dev 2023. All rights reserved."
|
||||||
long_description = """
|
long_description = """
|
||||||
Tool to turn long home movies into clips with less noise.
|
Tool to turn long home movies into clips with less noise.
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
|
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
use dioxus::hooks::use_future;
|
|
||||||
use lib;
|
use lib;
|
||||||
use base64::{engine::general_purpose, Engine as _};
|
use base64::{engine::general_purpose, Engine as _};
|
||||||
use core::cmp::Ordering;
|
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
dioxus_desktop::launch(App);
|
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!"
|
// define a component that renders a div with the text "Hello, world!"
|
||||||
|
|
@ -18,11 +20,19 @@ fn App(cx: Scope) -> Element {
|
||||||
let clipify_status = use_state(cx, || String::new());
|
let clipify_status = use_state(cx, || String::new());
|
||||||
let processing = use_state(cx, || false);
|
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"));
|
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! {
|
cx.render(rsx! {
|
||||||
header {
|
header {
|
||||||
title { "home-video-blue-extractinator" }
|
title { "home-video-blue-extractinator" }
|
||||||
style { "{a_css}" }
|
style { "{a_css} {processing_css()}" }
|
||||||
}
|
}
|
||||||
main {
|
main {
|
||||||
rsx! {
|
rsx! {
|
||||||
|
|
@ -33,10 +43,13 @@ fn App(cx: Scope) -> Element {
|
||||||
r#type: "file",
|
r#type: "file",
|
||||||
disabled: *processing.get(),
|
disabled: *processing.get(),
|
||||||
onchange: |evt| {
|
onchange: |evt| {
|
||||||
to_owned![file];
|
|
||||||
if let Some(file_engine) = &evt.files {
|
if let Some(file_engine) = &evt.files {
|
||||||
for f in &file_engine.files() {
|
for f in &file_engine.files() {
|
||||||
file.set(f.clone());
|
file.set(f.clone());
|
||||||
|
analyze_status.set(String::new());
|
||||||
|
clipify_status.set(String::new());
|
||||||
|
processing.set(false);
|
||||||
|
analysis.set(Analysis::new());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -109,7 +122,7 @@ fn App(cx: Scope) -> Element {
|
||||||
checked: a.has_content,
|
checked: a.has_content,
|
||||||
name: "{a.start}..{a.stop}",
|
name: "{a.start}..{a.stop}",
|
||||||
}
|
}
|
||||||
"{a.start}..{a.stop}: "
|
"{a.pretty_range()}"
|
||||||
br {}
|
br {}
|
||||||
img { src: "data:image/png;base64, {a.screenshot}" }
|
img { src: "data:image/png;base64, {a.screenshot}" }
|
||||||
}
|
}
|
||||||
|
|
@ -144,12 +157,33 @@ impl Analysis {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Analyzed {
|
struct Analyzed {
|
||||||
|
_start: f32,
|
||||||
|
_stop: f32,
|
||||||
start: String,
|
start: String,
|
||||||
stop: String,
|
stop: String,
|
||||||
screenshot: String,
|
screenshot: String,
|
||||||
has_content: bool,
|
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 {
|
async fn analyze(file: String) -> Analysis {
|
||||||
let content_spans = lib::video::inspect_async(&file).await;
|
let content_spans = lib::video::inspect_async(&file).await;
|
||||||
if content_spans.is_err() {
|
if content_spans.is_err() {
|
||||||
|
|
@ -174,11 +208,13 @@ async fn analyze(file: String) -> Analysis {
|
||||||
let screenshot = |content_span: &lib::video::ContentSpan| -> Analyzed {
|
let screenshot = |content_span: &lib::video::ContentSpan| -> Analyzed {
|
||||||
let ts = (content_span.start + content_span.stop) / 2.0;
|
let ts = (content_span.start + content_span.stop) / 2.0;
|
||||||
Analyzed {
|
Analyzed {
|
||||||
|
_start: content_span.start,
|
||||||
|
_stop: content_span.stop,
|
||||||
start: content_span.start.to_string(),
|
start: content_span.start.to_string(),
|
||||||
stop: content_span.stop.to_string(),
|
stop: content_span.stop.to_string(),
|
||||||
screenshot: match lib::video::screenshot_png(&file, ts) {
|
screenshot: match lib::video::screenshot_png(&file, ts) {
|
||||||
Ok(png) => general_purpose::STANDARD.encode(&png),
|
Ok(png) => general_purpose::STANDARD.encode(&png),
|
||||||
Err(_) => a_png.to_string(),
|
Err(_) => A_PNG.to_string(),
|
||||||
},
|
},
|
||||||
has_content: false,
|
has_content: false,
|
||||||
}
|
}
|
||||||
|
|
@ -221,9 +257,9 @@ async fn clipify(file: String, content_spans: Vec<lib::video::ContentSpan>) -> S
|
||||||
}
|
}
|
||||||
let _ = opener::open(d.clone());
|
let _ = opener::open(d.clone());
|
||||||
match statuses.len() {
|
match statuses.len() {
|
||||||
_ => statuses.join(", "),
|
|
||||||
0 => d,
|
0 => d,
|
||||||
|
_ => statuses.join(", "),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
Loading…
Reference in New Issue