init
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
4581
Cargo.lock
generated
Normal file
10
Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "ffmpegui"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
tauri = "2.6"
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = "2.3"
|
3
dev.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
export WEBKIT_DISABLE_DMABUF_RENDERER=1
|
||||
cargo tauri dev
|
24
frontend/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
13
frontend/index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
1599
frontend/package-lock.json
generated
Normal file
21
frontend/package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^2.6.0",
|
||||
"@vitejs/plugin-react": "^4.6.0",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.0.0"
|
||||
}
|
||||
}
|
121
frontend/src/App.jsx
Normal file
@ -0,0 +1,121 @@
|
||||
import React, { useState, useRef } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { open } from "@tauri-apps/plugin-dialog";
|
||||
import "./style.css";
|
||||
|
||||
// Simple debounce hook
|
||||
function useDebouncedCallback(callback, delay) {
|
||||
const timeoutRef = useRef(null);
|
||||
return (...args) => {
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||
timeoutRef.current = setTimeout(() => {
|
||||
callback(...args);
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [result, setResult] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [inputPath, setInputPath] = useState("");
|
||||
const [format, setFormat] = useState("mp4");
|
||||
const [videoCodec, setVideoCodec] = useState("x264");
|
||||
const [preset, setPreset] = useState("veryslow");
|
||||
|
||||
const handlePickFile = async () => {
|
||||
const selected = await open({
|
||||
filters: [
|
||||
{ name: "Videos", extensions: ["mp4", "mkv", "webm", "mov", "avi"] },
|
||||
],
|
||||
});
|
||||
if (typeof selected === "string") {
|
||||
setInputPath(selected);
|
||||
}
|
||||
};
|
||||
|
||||
const handleReencode = async () => {
|
||||
if (!inputPath) {
|
||||
setResult("Please select a video file.");
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setResult("Re-encoding...");
|
||||
try {
|
||||
invoke("reencode_video", {
|
||||
inputPath,
|
||||
outputFormat: format,
|
||||
videoCodec,
|
||||
preset,
|
||||
}).then(setResult);
|
||||
} catch (e) {
|
||||
setResult("Error: " + e);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const debouncedReencode = useDebouncedCallback(handleReencode, 1000);
|
||||
|
||||
return (
|
||||
<div className="card">
|
||||
<button type="button" onClick={handlePickFile} disabled={loading}>
|
||||
Select Video
|
||||
</button>
|
||||
<span style={{ marginLeft: 8 }}>{inputPath ? inputPath : "No file selected"}</span>
|
||||
<div style={{ margin: "12px 0" }}>
|
||||
<label htmlFor="format-select">Output format: </label>
|
||||
<select
|
||||
id="format-select"
|
||||
value={format}
|
||||
onChange={e => setFormat(e.target.value)}
|
||||
disabled={loading}
|
||||
>
|
||||
<option value="mp4">mp4</option>
|
||||
<option value="mkv">mkv</option>
|
||||
<option value="webm">webm</option>
|
||||
<option value="mov">mov</option>
|
||||
<option value="avi">avi</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style={{ margin: "12px 0" }}>
|
||||
<label htmlFor="codec-select">Video codec: </label>
|
||||
<select
|
||||
id="codec-select"
|
||||
value={videoCodec}
|
||||
onChange={e => setVideoCodec(e.target.value)}
|
||||
disabled={loading}
|
||||
>
|
||||
<option value="x264">x264</option>
|
||||
<option value="x265">x265</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style={{ margin: "12px 0" }}>
|
||||
<label htmlFor="preset-select">Preset: </label>
|
||||
<select
|
||||
id="preset-select"
|
||||
value={preset}
|
||||
onChange={e => setPreset(e.target.value)}
|
||||
disabled={loading}
|
||||
>
|
||||
<option value="veryslow">veryslow</option>
|
||||
<option value="slower">slower</option>
|
||||
<option value="slow">slow</option>
|
||||
<option value="medium">medium</option>
|
||||
<option value="fast">fast</option>
|
||||
<option value="faster">faster</option>
|
||||
<option value="ultrafast">ultrafast</option>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
id="reencode-btn"
|
||||
type="button"
|
||||
onClick={debouncedReencode}
|
||||
disabled={loading || !inputPath}
|
||||
>
|
||||
Re-encode Video
|
||||
</button>
|
||||
{loading && <div className="spinner" aria-label="Encoding in progress" />}
|
||||
<p id="ffmpeg-result">{result}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
7
frontend/src/main.jsx
Normal file
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import App from './App.jsx';
|
||||
import './style.css';
|
||||
|
||||
const root = createRoot(document.getElementById('app'));
|
||||
root.render(<App />);
|
112
frontend/src/style.css
Normal file
@ -0,0 +1,112 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
#app {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.vanilla:hover {
|
||||
filter: drop-shadow(0 0 2em #f7df1eaa);
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
|
||||
.spinner {
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid #646cff;
|
||||
border-radius: 50%;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
animation: spin 1s linear infinite;
|
||||
display: inline-block;
|
||||
margin: 12px auto;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
6
frontend/vite.config.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
});
|
4
src-tauri/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
/gen/schemas
|
5043
src-tauri/Cargo.lock
generated
Normal file
28
src-tauri/Cargo.toml
Normal file
@ -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" ]
|
3
src-tauri/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
18
src-tauri/capabilities/default.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
BIN
src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 49 KiB |
60
src-tauri/src/lib.rs
Normal file
@ -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");
|
||||
}
|
6
src-tauri/src/main.rs
Normal file
@ -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();
|
||||
}
|
36
src-tauri/tauri.conf.json
Normal file
@ -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"
|
||||
}
|
1
src/main.rs
Normal file
@ -0,0 +1 @@
|
||||
fn main() {}
|