121 lines
3.5 KiB
HTML
121 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>FFmpeg Transcoder</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background: #1e1e1e;
|
|
color: #fff;
|
|
padding: 2rem;
|
|
}
|
|
h1 {
|
|
color: #4fc3f7;
|
|
}
|
|
label, input, select, textarea, button {
|
|
display: block;
|
|
margin: 1rem 0;
|
|
width: 100%;
|
|
}
|
|
input, select, textarea {
|
|
padding: 0.5rem;
|
|
background: #333;
|
|
color: #fff;
|
|
border: 1px solid #555;
|
|
border-radius: 4px;
|
|
}
|
|
button {
|
|
background: #4fc3f7;
|
|
color: #000;
|
|
padding: 0.7rem;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
border: none;
|
|
border-radius: 4px;
|
|
}
|
|
#log {
|
|
background: #222;
|
|
padding: 1rem;
|
|
margin-top: 1rem;
|
|
height: 200px;
|
|
overflow-y: auto;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>FFmpeg Web Transcoder</h1>
|
|
|
|
<form id="upload-form">
|
|
<label for="yamlFile">Upload YAML Config:</label>
|
|
<input type="file" id="yamlFile" name="yamlFile" accept=".yml, .yaml" required />
|
|
<button type="submit">Upload & Transcode</button>
|
|
</form>
|
|
|
|
<label for="presetSelect">Or Select a Preset:</label>
|
|
<select id="presetSelect">
|
|
<option disabled selected>Loading presets...</option>
|
|
</select>
|
|
<button onclick="loadPreset()">Load Preset</button>
|
|
|
|
<label for="fileBrowser">Select Input File:</label>
|
|
<input type="text" id="inputFile" placeholder="/data/input.mp4" />
|
|
|
|
<button onclick="startTranscode()">Start Transcoding</button>
|
|
|
|
<div id="log"></div>
|
|
|
|
<script>
|
|
const presetSelect = document.getElementById('presetSelect');
|
|
|
|
async function fetchPresets() {
|
|
const res = await fetch('http://localhost:8000/list-presets/');
|
|
const data = await res.json();
|
|
presetSelect.innerHTML = data.presets.map(p => `<option value="${p}">${p}</option>`).join('');
|
|
}
|
|
|
|
async function loadPreset() {
|
|
const preset = presetSelect.value;
|
|
const res = await fetch(`http://localhost:8000/preset/${preset}`);
|
|
const text = await res.text();
|
|
alert(`Loaded Preset: \n\n${text}`);
|
|
}
|
|
|
|
document.getElementById('upload-form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const fileInput = document.getElementById('yamlFile');
|
|
const formData = new FormData();
|
|
formData.append('file', fileInput.files[0]);
|
|
|
|
const res = await fetch('http://localhost:8000/upload-config/', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
const result = await res.json();
|
|
document.getElementById('log').innerText = JSON.stringify(result, null, 2);
|
|
});
|
|
|
|
async function startTranscode() {
|
|
const inputPath = document.getElementById('inputFile').value;
|
|
const preset = presetSelect.value;
|
|
const presetRes = await fetch(`http://localhost:8000/preset/${preset}`);
|
|
const yamlText = await presetRes.text();
|
|
const yamlObj = jsyaml.load(yamlText);
|
|
yamlObj.input_file = inputPath;
|
|
|
|
const res = await fetch('http://localhost:8000/transcode/', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(yamlObj)
|
|
});
|
|
const result = await res.json();
|
|
document.getElementById('log').innerText = JSON.stringify(result, null, 2);
|
|
}
|
|
|
|
window.onload = fetchPresets;
|
|
</script>
|
|
<script src="https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/dist/js-yaml.min.js"></script>
|
|
</body>
|
|
</html>
|