init
This commit is contained in:
@@ -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?
|
||||
@@ -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>
|
||||
Generated
+1599
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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 />);
|
||||
@@ -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); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
});
|
||||
Reference in New Issue
Block a user