RandomPersonRR commited on
Commit
c950606
·
verified ·
1 Parent(s): 8df4907

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +71 -56
index.html CHANGED
@@ -3,76 +3,91 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>FFmpeg Web Interface</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
- <h1>FFmpeg Web Interface</h1>
10
 
11
- <!-- File Upload Section -->
12
- <h2>Upload File</h2>
13
- <input type="file" id="fileUpload" />
14
- <button onclick="uploadFile()">Upload</button>
 
 
 
15
 
16
- <!-- HTML Audio Player -->
17
- <h2>Audio Player</h2>
18
- <audio id="audioPlayer" controls></audio>
 
 
19
 
20
- <!-- HTML Video Player -->
21
- <h2>Video Player</h2>
22
- <video id="videoPlayer" controls width="600"></video>
 
 
23
 
24
- <!-- Command Input -->
25
- <h2>Command Input</h2>
26
- <textarea id="commandInput" rows="4" cols="50" placeholder="Enter FFmpeg commands here..."></textarea>
27
- <button onclick="executeCommand()">Execute Command</button>
28
-
29
- <!-- Logs Section -->
30
- <h2>Logs</h2>
31
- <pre id="logs"></pre>
32
 
33
  <script>
34
- function uploadFile() {
35
- const fileInput = document.getElementById('fileUpload');
36
- const file = fileInput.files[0];
37
- if (file) {
38
- const formData = new FormData();
39
- formData.append('file', file);
40
-
41
- fetch('/upload', {
42
- method: 'POST',
43
- body: formData
44
- }).then(response => response.text())
45
- .then(data => {
46
- document.getElementById('logs').textContent = data;
47
- const audioPlayer = document.getElementById('audioPlayer');
48
- const videoPlayer = document.getElementById('videoPlayer');
49
- const fileUrl = URL.createObjectURL(file);
50
-
51
- // Display appropriate player based on file type
52
- if (file.type.startsWith('audio/')) {
53
- audioPlayer.src = fileUrl;
54
- audioPlayer.style.display = 'block';
55
- videoPlayer.style.display = 'none';
56
- } else if (file.type.startsWith('video/')) {
57
- videoPlayer.src = fileUrl;
58
- videoPlayer.style.display = 'block';
59
- audioPlayer.style.display = 'none';
60
- }
61
- });
62
- }
63
- }
64
 
65
- function executeCommand() {
66
  const command = document.getElementById('commandInput').value;
67
- fetch('/execute', {
68
  method: 'POST',
69
  headers: { 'Content-Type': 'application/json' },
70
- body: JSON.stringify({ command })
71
- }).then(response => response.text())
72
  .then(data => {
73
- document.getElementById('logs').textContent = data;
 
 
 
 
 
 
 
 
74
  });
75
- }
76
  </script>
77
  </body>
78
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>FFmpeg Command Executor</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ margin: 20px;
11
+ }
12
+ textarea {
13
+ width: 100%;
14
+ height: 100px;
15
+ }
16
+ .log, .player {
17
+ margin-top: 20px;
18
+ }
19
+ #videoPlayer {
20
+ display: none;
21
+ width: 100%;
22
+ height: auto;
23
+ }
24
+ </style>
25
  </head>
26
  <body>
27
+ <h1>FFmpeg Command Executor</h1>
28
 
29
+ <!-- File upload form -->
30
+ <form id="uploadForm" enctype="multipart/form-data">
31
+ <label for="fileInput">Upload a file:</label>
32
+ <input type="file" id="fileInput" name="file" required>
33
+ <br><br>
34
+ <input type="submit" value="Upload">
35
+ </form>
36
 
37
+ <!-- Command input -->
38
+ <h2>FFmpeg Command</h2>
39
+ <textarea id="commandInput" placeholder="Enter FFmpeg command here..."></textarea>
40
+ <br>
41
+ <button id="runCommand">Run Command</button>
42
 
43
+ <!-- Logs and video player -->
44
+ <div class="log">
45
+ <h2>FFmpeg Logs</h2>
46
+ <pre id="logOutput"></pre>
47
+ </div>
48
 
49
+ <div class="player">
50
+ <h2>Processed Video</h2>
51
+ <video id="videoPlayer" controls>
52
+ <source id="videoSource" src="" type="video/mp4">
53
+ Your browser does not support the video tag.
54
+ </video>
55
+ </div>
 
56
 
57
  <script>
58
+ document.getElementById('uploadForm').addEventListener('submit', function(event) {
59
+ event.preventDefault();
60
+ const formData = new FormData(this);
61
+ fetch('/upload', {
62
+ method: 'POST',
63
+ body: formData
64
+ }).then(response => response.text())
65
+ .then(text => {
66
+ document.getElementById('logOutput').textContent = 'File uploaded successfully.';
67
+ }).catch(error => {
68
+ document.getElementById('logOutput').textContent = 'Error uploading file: ' + error.message;
69
+ });
70
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
+ document.getElementById('runCommand').addEventListener('click', function() {
73
  const command = document.getElementById('commandInput').value;
74
+ fetch('/run', {
75
  method: 'POST',
76
  headers: { 'Content-Type': 'application/json' },
77
+ body: JSON.stringify({ command: command })
78
+ }).then(response => response.json())
79
  .then(data => {
80
+ document.getElementById('logOutput').textContent = data.logs;
81
+ if (data.videoUrl) {
82
+ const videoPlayer = document.getElementById('videoPlayer');
83
+ const videoSource = document.getElementById('videoSource');
84
+ videoSource.src = data.videoUrl;
85
+ videoPlayer.style.display = 'block';
86
+ }
87
+ }).catch(error => {
88
+ document.getElementById('logOutput').textContent = 'Error running command: ' + error.message;
89
  });
90
+ });
91
  </script>
92
  </body>
93
  </html>