Skip to content

Used to rotate MP4 video, no ffmpeg, no re-encoding, can be used on both the Web side and the Node side.

Notifications You must be signed in to change notification settings

xiefengnian/mp4transpose.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MP4 rotate

Used to rotate MP4 video, no ffmpeg, no re-encoding, can be used on both the Web side and the Node side. The implementation principle is as follows:

stackoverflow: rotate-mp4-videos-without-re-encoding

!!!Notice: Browser memory is limited, and too large a video may throw an error.

Install

$ npm install mp4transpose

Usage

See the example folder for more information.

1. web

with webpack

import transpose from 'mp4transpose';
const input = document.getElementById('input');
input.onchange = function () {
    const file = input.files[0];
    file.arrayBuffer().then(val => {
        const mp4Buffer = transpose(val, '270'); // rotate mp4 from ab
        const mp4 = new File([mp4Buffer], 'output.mp4', { type: 'video/mp4' }); // create a new mp4 file from ab
        const url = URL.createObjectURL(mp4);
        window.open(url);
    })
}

with dist

<script src="~@mp4Transpose/dist/bundle.js"></script>
<script>
    const transpose = window.mp4Transpose;
</script>

2. Node.js

As above.

Arguments

transpose(mp4File, rotate): Uint8Array | Buffer

  • mp4File: ArrayBuffer

    the MP4 file you want to rotate

  • rotate: "0" | "90" | "180" | "270"

    the ratation of ouput mp4 file

About

Used to rotate MP4 video, no ffmpeg, no re-encoding, can be used on both the Web side and the Node side.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published