Spaces:
Sleeping
Sleeping
RandomPersonRR
commited on
Update index.html
Browse files- 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
</head>
|
8 |
<body>
|
9 |
-
<h1>FFmpeg
|
10 |
|
11 |
-
<!-- File
|
12 |
-
<
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
15 |
|
16 |
-
<!--
|
17 |
-
<h2>
|
18 |
-
<
|
|
|
|
|
19 |
|
20 |
-
<!--
|
21 |
-
<
|
22 |
-
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
<pre id="logs"></pre>
|
32 |
|
33 |
<script>
|
34 |
-
function
|
35 |
-
|
36 |
-
const
|
37 |
-
|
38 |
-
|
39 |
-
formData
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
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
|
66 |
const command = document.getElementById('commandInput').value;
|
67 |
-
fetch('/
|
68 |
method: 'POST',
|
69 |
headers: { 'Content-Type': 'application/json' },
|
70 |
-
body: JSON.stringify({ command })
|
71 |
-
}).then(response => response.
|
72 |
.then(data => {
|
73 |
-
document.getElementById('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
|