convert-video

1.0.0 • Public • Published

convert-video

A lightweight video conversion tool to convert mp4, avi and mov file.

DEMO

Install

npm install convert-video

Usage

import VideoConverter from 'convert-video'

VideoConverter.convert(sourceVideoFile, targetVideoFormat);

Example Code

<input type='file' accept=".mp4, .avi, .mov" onchange="convertVideo(this)" />

import VideoConverter from 'convert-video'

async function convertVideo(input) {
    let sourceVideoFile = input.files[0];
    let targetVideoFormat = 'avi'
    let convertedVideoDataObj = await VideoConverter.convert(sourceVideoFile, targetVideoFormat);
}
This convert function will return a converted video data object which includes video file's name, format and blob URL.
This blob URL can be used to download the converted video.
function downloadVideo(convertedVideoDataObj) {
    let a = document.createElement("a");
    a.href = convertedVideoDataObj.data;
    a.download = convertedVideoDataObj.name + "." + convertedVideoDataObj.format;
    a.click();
}

License

MIT

Package Sidebar

Install

npm i convert-video

Weekly Downloads

156

Version

1.0.0

License

MIT

Unpacked Size

4.8 kB

Total Files

4

Last publish

Collaborators

  • sdn101