Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>FFmpeg Web Interface</title> | |
</head> | |
<body> | |
<h1>FFmpeg Web Interface</h1> | |
<!-- File Upload Section --> | |
<h2>Upload File</h2> | |
<input type="file" id="fileUpload" /> | |
<button onclick="uploadFile()">Upload</button> | |
<!-- HTML Audio Player --> | |
<h2>Audio Player</h2> | |
<audio id="audioPlayer" controls></audio> | |
<!-- HTML Video Player --> | |
<h2>Video Player</h2> | |
<video id="videoPlayer" controls width="600"></video> | |
<!-- Command Input --> | |
<h2>Command Input</h2> | |
<textarea id="commandInput" rows="4" cols="50" placeholder="Enter FFmpeg commands here..."></textarea> | |
<button onclick="executeCommand()">Execute Command</button> | |
<!-- Logs Section --> | |
<h2>Logs</h2> | |
<pre id="logs"></pre> | |
<script> | |
function uploadFile() { | |
const fileInput = document.getElementById('fileUpload'); | |
const file = fileInput.files[0]; | |
if (file) { | |
const formData = new FormData(); | |
formData.append('file', file); | |
fetch('/upload', { | |
method: 'POST', | |
body: formData | |
}).then(response => response.text()) | |
.then(data => { | |
document.getElementById('logs').textContent = data; | |
const audioPlayer = document.getElementById('audioPlayer'); | |
const videoPlayer = document.getElementById('videoPlayer'); | |
const fileUrl = URL.createObjectURL(file); | |
// Display appropriate player based on file type | |
if (file.type.startsWith('audio/')) { | |
audioPlayer.src = fileUrl; | |
audioPlayer.style.display = 'block'; | |
videoPlayer.style.display = 'none'; | |
} else if (file.type.startsWith('video/')) { | |
videoPlayer.src = fileUrl; | |
videoPlayer.style.display = 'block'; | |
audioPlayer.style.display = 'none'; | |
} | |
}); | |
} | |
} | |
function executeCommand() { | |
const command = document.getElementById('commandInput').value; | |
fetch('/execute', { | |
method: 'POST', | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ command }) | |
}).then(response => response.text()) | |
.then(data => { | |
document.getElementById('logs').textContent = data; | |
}); | |
} | |
</script> | |
</body> | |
</html> |