How can I get the video duration in Node Js using video buffer data?

1.5k views Asked by At

Hope everyone doing well.

I have a nodejs project, in which I am allowing the end user to upload images/videos. And in nodejs (express) I am receiving the media file using express-fileupload package, which basically attaches files property in request object. Now I want to check the video duration from the buffer data which express-fileupload attaches to the request object.

Here is the req.files object structure:

{
  media: {
    name: 'filename.mp4',
    data: <Buffer 00 00 00 18 66 74 79 70 6d 70 34 32 00 00 00 00 69 73 6f 6d 6d 70 34 32 00 00 27 03 6d 6f 6f 76 00 00 00 6c 6d 76 68 64 00 00 00 00 d9 af 85 a8 d9 af ... 1832626 more bytes>,
    size: 1832676,
    encoding: '7bit',
    tempFilePath: '',
    truncated: false,
    mimetype: 'video/mp4',
    md5: 'e01d7091f886e84769c2c05c77a83a06',
    mv: [Function: mv]
  }
}

** Note: size is available in bytes. (e.g: 1832676 / 1000000 = 1.8 MB video)

Now using this Buffer data, I want to check the duration of this video. I can check mimetype/extension & size of video, but not able to check the duration.

Any package is available out there or any other way of checking the duration?

Any kind of help will be greatly appreciated.

0

There are 0 answers