Spaces:
Paused
Paused
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>FFmpeg Command Executor</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| margin: 20px; | |
| } | |
| textarea { | |
| width: 100%; | |
| height: 100px; | |
| } | |
| .log, .player { | |
| margin-top: 20px; | |
| } | |
| #videoPlayer { | |
| display: none; | |
| width: 100%; | |
| height: auto; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>FFmpeg Command Executor</h1> | |
| <!-- File upload form --> | |
| <form id="uploadForm" enctype="multipart/form-data"> | |
| <label for="fileInput">Upload a file:</label> | |
| <input type="file" id="fileInput" name="file" required> | |
| <br><br> | |
| <input type="submit" value="Upload"> | |
| </form> | |
| <!-- Command input --> | |
| <h2>FFmpeg Command</h2> | |
| <textarea id="commandInput" placeholder="Enter FFmpeg command here..."></textarea> | |
| <br> | |
| <button id="runCommand">Run Command</button> | |
| <!-- Logs and video player --> | |
| <div class="log"> | |
| <h2>FFmpeg Logs</h2> | |
| <pre id="logOutput"></pre> | |
| </div> | |
| <div class="player"> | |
| <h2>Processed Video</h2> | |
| <video id="videoPlayer" controls> | |
| <source id="videoSource" src="" type="video/mp4"> | |
| Your browser does not support the video tag. | |
| </video> | |
| </div> | |
| <script> | |
| document.getElementById('uploadForm').addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| const formData = new FormData(this); | |
| fetch('/upload', { | |
| method: 'POST', | |
| body: formData | |
| }).then(response => response.text()) | |
| .then(text => { | |
| document.getElementById('logOutput').textContent = 'File uploaded successfully.'; | |
| }).catch(error => { | |
| document.getElementById('logOutput').textContent = 'Error uploading file: ' + error.message; | |
| }); | |
| }); | |
| document.getElementById('runCommand').addEventListener('click', function() { | |
| const command = document.getElementById('commandInput').value; | |
| fetch('/run', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ command: command }) | |
| }).then(response => response.json()) | |
| .then(data => { | |
| document.getElementById('logOutput').textContent = data.logs; | |
| if (data.videoUrl) { | |
| const videoPlayer = document.getElementById('videoPlayer'); | |
| const videoSource = document.getElementById('videoSource'); | |
| videoSource.src = data.videoUrl; | |
| videoPlayer.style.display = 'block'; | |
| } | |
| }).catch(error => { | |
| document.getElementById('logOutput').textContent = 'Error running command: ' + error.message; | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |