Created
October 2, 2024 20:43
-
-
Save JonnyBurger/80b9ca9731c02c0c4feef318dae90a65 to your computer and use it in GitHub Desktop.
Convert the full 10min Big Buck Bunny movie from MP4 to WebM. Needs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Does not work with file:// protocol --> | |
<!-- You need to serve this via localhost, e.g `npx serve .` --> | |
<script type="importmap"> | |
{ | |
"imports": { | |
"@remotion/media-parser/web-fs": "https://unpkg.com/@remotion/[email protected]/dist/esm/web-fs.mjs", | |
"@remotion/media-parser/buffer": "https://unpkg.com/@remotion/[email protected]/dist/esm/buffer.mjs", | |
"@remotion/media-parser": "https://unpkg.com/@remotion/[email protected]/dist/esm/index.mjs", | |
"webcodecs": "https://unpkg.com/@remotion/[email protected]/dist/esm/index.mjs" | |
} | |
} | |
</script> | |
<button>Convert video</button> | |
<div id="progress">Progress =</div> | |
<script type="module"> | |
import { convertMedia } from "webcodecs"; | |
const button = document.querySelector("button"); | |
button.addEventListener("click", async () => { | |
const fn = await convertMedia({ | |
src: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", | |
onMediaStateUpdate: (s) => { | |
const progress = document.querySelector("#progress"); | |
progress.innerText = `Progress = ${JSON.stringify(s)}`; | |
}, | |
videoCodec: "vp9", | |
audioCodec: "opus", | |
to: "webm", | |
}); | |
const file = await fn.save(); | |
const a = document.createElement("a"); | |
a.href = URL.createObjectURL(file); | |
a.download = "hithere"; | |
a.click(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment