init
@@ -0,0 +1,4 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
||||
@@ -0,0 +1,28 @@
|
||||
[package]
|
||||
name = "app"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
license = ""
|
||||
repository = ""
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
name = "app_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.3", features = [] }
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "2.6", features = [] }
|
||||
tauri-plugin-dialog = "2.3"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devUrl` points to the filesystem
|
||||
# DO NOT REMOVE!!
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default-plugins",
|
||||
"description": "enables the default permissions",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:path:default",
|
||||
"core:event:default",
|
||||
"core:window:default",
|
||||
"core:webview:default",
|
||||
"core:app:default",
|
||||
"core:resources:default",
|
||||
"core:menu:default",
|
||||
"core:tray:default",
|
||||
"dialog:allow-open",
|
||||
"dialog:default"
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 49 KiB |
@@ -0,0 +1,60 @@
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use tauri::command;
|
||||
|
||||
#[command]
|
||||
fn reencode_video(
|
||||
input_path: String,
|
||||
output_format: String,
|
||||
video_codec: Option<String>,
|
||||
preset: Option<String>,
|
||||
) -> Result<String, String> {
|
||||
// Determine output path
|
||||
let input = Path::new(&input_path);
|
||||
let stem = input
|
||||
.file_stem()
|
||||
.and_then(|s| s.to_str())
|
||||
.ok_or("Invalid input file name")?;
|
||||
let parent = input.parent().unwrap_or_else(|| Path::new("."));
|
||||
let output_path = parent.join(format!("{}_reencoded.{}", stem, output_format));
|
||||
|
||||
// Set codec and preset, with defaults
|
||||
let codec = video_codec.unwrap_or_else(|| "x264".to_string());
|
||||
let preset = preset.unwrap_or_else(|| "veryslow".to_string());
|
||||
let codec_flag = match codec.as_str() {
|
||||
"x264" => "libx264",
|
||||
"x265" => "libx265",
|
||||
other => other, // fallback, allow custom
|
||||
};
|
||||
|
||||
// Build ffmpeg command
|
||||
let status = Command::new("ffmpeg")
|
||||
.arg("-y")
|
||||
.arg("-i")
|
||||
.arg(&input_path)
|
||||
.arg("-c:v")
|
||||
.arg(codec_flag)
|
||||
.arg("-preset")
|
||||
.arg(&preset)
|
||||
.arg(output_path.to_str().unwrap())
|
||||
.status()
|
||||
.map_err(|e| format!("Failed to start ffmpeg: {}", e))?;
|
||||
|
||||
if status.success() {
|
||||
Ok(format!(
|
||||
"Re-encoded video saved to: {}",
|
||||
output_path.display()
|
||||
))
|
||||
} else {
|
||||
Err("ffmpeg failed to re-encode the video".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.invoke_handler(tauri::generate_handler![reencode_video])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
app_lib::run();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"app": {
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"fullscreen": false,
|
||||
"height": 600,
|
||||
"resizable": true,
|
||||
"title": "FFMPEGUI",
|
||||
"width": 800
|
||||
}
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"beforeBuildCommand": "cd frontend && npm run build",
|
||||
"beforeDevCommand": "cd frontend && npm run dev",
|
||||
"devUrl": "http://localhost:5173",
|
||||
"frontendDist": "../frontend/dist"
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"targets": "all"
|
||||
},
|
||||
"identifier": "rocks.ipost.code002lover.ffmpegui",
|
||||
"productName": "FFMPEGUI",
|
||||
"version": "0.1.0"
|
||||
}
|
||||