0.1.1 • Published 6 months ago

media-trimmer v0.1.1

Weekly downloads
-
License
AGPL-3.0-only
Repository
-
Last release
6 months ago

A video trimmer in the browser

Screenshot

https://demo.miru.media/trim/

npm install media-trimmer
import { trim } from 'media-trimmer'

try {
  // The input video must be a `.mp4`/`.mov` file with a video track
  // and the browser must support video encoding with the WebCodecs API
  await trim('video.mp4', {
    start: 2, //    start time in seconds
    end: 10, //     end time in seconds
    mute: false, // ignore the audio track?
  })
} catch (error) {
  alert(error)
}

It also comes with a Web Component UI:

<!-- after importing the library, the <media-trimmer> custom element will be defined -->
<media-trimmer id="trimmer" source="video.mp4"></media-trimmer>

<button id="export" type="buton">Get trimmed video</button>

<script>
const trimmer = document.getElementById('trimmer')
const export = document.getElementById('export')

button.addEventListener('click', () => console.log(await trimmer.toBlob()))
trimmer.addEventListener('progress', (event) => console.log('progress:', event.detail.progress))
<script>

Powered by:

Roadmap

  • Lossless trimming
  • Bitrate/filesize controls
  • Webm support
  • Color profile preservation
  • Increased browser and codec support via LibAVJS-WebCodecs-Polyfill

Funding

This project is funded through NGI Zero Core, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

0.1.1

6 months ago

0.1.0

6 months ago

0.0.1

8 months ago

0.0.0

8 months ago