Spaces:
Running
Running
nicehero
commited on
Commit
·
601dcea
1
Parent(s):
05d832a
delete
Browse files- trim2.html +0 -45
trim2.html
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
<html>
|
| 2 |
-
<head>
|
| 3 |
-
<link rel="stylesheet" href="style.css">
|
| 4 |
-
<script src="assets/ffmpeg/package/dist/umd/ffmpeg.js"></script>
|
| 5 |
-
<script src="assets/util/package/dist/umd/index.js"></script>
|
| 6 |
-
</head>
|
| 7 |
-
<body>
|
| 8 |
-
<h3>Upload a mp4 (x264) video and trim its first 1 seconds and play!</h3>
|
| 9 |
-
<video id="output-video" controls></video><br/>
|
| 10 |
-
<input type="file" id="uploader">
|
| 11 |
-
<p id="message"></p>
|
| 12 |
-
<script>
|
| 13 |
-
const { fetchFile } = FFmpegUtil;
|
| 14 |
-
const { FFmpeg } = FFmpegWASM;
|
| 15 |
-
let ffmpeg = null;
|
| 16 |
-
|
| 17 |
-
const trim = async ({ target: { files } }) => {
|
| 18 |
-
const message = document.getElementById('message');
|
| 19 |
-
if (ffmpeg === null) {
|
| 20 |
-
ffmpeg = new FFmpeg();
|
| 21 |
-
ffmpeg.on("log", ({ message }) => {
|
| 22 |
-
console.log(message);
|
| 23 |
-
})
|
| 24 |
-
ffmpeg.on("progress", ({ progress }) => {
|
| 25 |
-
message.innerHTML = `${progress * 100} %`;
|
| 26 |
-
});
|
| 27 |
-
await ffmpeg.load({
|
| 28 |
-
coreURL: "assets/core/package/dist/umd/ffmpeg-core.js",
|
| 29 |
-
});
|
| 30 |
-
}
|
| 31 |
-
const { name } = files[0];
|
| 32 |
-
await ffmpeg.writeFile(name, await fetchFile(files[0]));
|
| 33 |
-
message.innerHTML = 'Start trimming';
|
| 34 |
-
await ffmpeg.exec(['-i', name, '-ss', '0', '-to', '1', 'output.mp4']);
|
| 35 |
-
message.innerHTML = 'Complete trimming';
|
| 36 |
-
const data = await ffmpeg.readFile('output.mp4');
|
| 37 |
-
|
| 38 |
-
const video = document.getElementById('output-video');
|
| 39 |
-
video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
|
| 40 |
-
}
|
| 41 |
-
const elm = document.getElementById('uploader');
|
| 42 |
-
elm.addEventListener('change', trim);
|
| 43 |
-
</script>
|
| 44 |
-
</body>
|
| 45 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|