diff --git a/Cargo.toml b/Cargo.toml index 33dd092..805b0c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,10 @@ [package] name = "clipper" version = "0.2.1" -edition = "2021" \ No newline at end of file +edition = "2021" + +[lib] +path = "src/main.rs" + +[dependencies] +serde = { version = "1", features = ["derive"] } \ No newline at end of file diff --git a/src/clipper.rs b/src/clipper.rs index 1d9dade..f6ec673 100644 --- a/src/clipper.rs +++ b/src/clipper.rs @@ -2,13 +2,15 @@ use crate::{ error, ffmpeg::{Encoder, Inputs, Output}, }; +use serde::{Deserialize, Serialize}; use std::{ env::args, process::{exit, Command}, vec::IntoIter, }; -#[derive(Default)] +#[derive(Serialize, Deserialize, Default, Debug)] +#[serde(rename_all = "camelCase")] pub struct Clipper { pub inputs: Inputs, pub encoder: Encoder, diff --git a/src/ffmpeg/encoder.rs b/src/ffmpeg/encoder.rs index 80587eb..7a7e18e 100644 --- a/src/ffmpeg/encoder.rs +++ b/src/ffmpeg/encoder.rs @@ -1,7 +1,9 @@ use crate::{error, string_vec}; +use serde::{Deserialize, Serialize}; use std::vec::IntoIter; -#[derive(Default)] +#[derive(Serialize, Deserialize, Default, Debug)] +#[serde(rename_all = "camelCase")] pub struct Encoder { nvenc: bool, hevc: bool, diff --git a/src/ffmpeg/input.rs b/src/ffmpeg/input.rs index c92b990..dda9fa6 100644 --- a/src/ffmpeg/input.rs +++ b/src/ffmpeg/input.rs @@ -1,5 +1,8 @@ use crate::{error, ffmpeg::duration_to_secs}; +use serde::{Deserialize, Serialize}; +#[derive(Serialize, Deserialize, Default, Debug)] +#[serde(rename_all = "camelCase")] pub struct Input { pub file: String, pub segments: Vec<(f64, f64)>, diff --git a/src/ffmpeg/inputs.rs b/src/ffmpeg/inputs.rs index 9636934..366a4ed 100644 --- a/src/ffmpeg/inputs.rs +++ b/src/ffmpeg/inputs.rs @@ -3,9 +3,11 @@ use crate::{ ffmpeg::{escape_ffmpeg_chars, Input}, string_vec, }; +use serde::{Deserialize, Serialize}; use std::vec::IntoIter; -#[derive(Default)] +#[derive(Serialize, Deserialize, Default, Debug)] +#[serde(rename_all = "camelCase")] pub struct Inputs { inputs: Vec, fade: f64, diff --git a/src/ffmpeg/output.rs b/src/ffmpeg/output.rs index bf44031..81f6158 100644 --- a/src/ffmpeg/output.rs +++ b/src/ffmpeg/output.rs @@ -1,7 +1,9 @@ use crate::{error, string_vec}; +use serde::{Deserialize, Serialize}; use std::vec::IntoIter; -#[derive(Default)] +#[derive(Serialize, Deserialize, Default, Debug)] +#[serde(rename_all = "camelCase")] pub struct Output { file: Option, force_overwrite: bool, diff --git a/src/main.rs b/src/main.rs index a65ef06..ab51874 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,8 @@ mod clipper; mod ffmpeg; -use clipper::Clipper; +pub use clipper::Clipper; -fn main() { - Clipper::new().run(); +pub fn main() { + Clipper::from_args().run(); }