tgdn tgdn - 1 month ago 20x
Node.js Question

Get video resolution in nodejs

I have been trying to get an answer to this without really finding any. Excuse me if this sounds stupid or obvious.

I have a nodejs application and basically I would like to simply get the resolution of a video. Imagine I have film stored on disk and I would like to be able to know if it is in 720p or 1080p or anything else.

I understood that I might need to use ffmpeg to do so, but then I also understood that ffmpeg was mostly used to "record, convert and stream audio and video files".
That does not mean retrieve video resolution.

Thank you for your help

Edit 1:
The node.js app is a desktop app and needs to be portable to Linux, windows and OS X. If possible a portable answer would be more appreciated but of course any answer is welcome.


To be honest I think the best method I found was to use fluent-ffmpeg with ffprobe as you are able to set the the path to the executable. The only problem is that ffmpeg has to be shipped with the app. So different executables have to be shipped, one for each distribution/os/derivation. If anyone has anything better I am open to answers.

Getting the width, height and aspect ratio using fluent-ffmpeg is done like so:

var ffmpeg = require('fluent-ffmpeg');


ffmpeg.ffprobe(pathToYourVideo, function(err, metadata) {
    if (err) {
    } elseĀ {
        // metadata should contain 'width', 'height' and 'display_aspect_ratio'