Search code examples
javascriptnode.jsffmpegnode-webkitavi

Node-Webkit Get video duration from avi file path


I'm looking for a way to get the video duration from avi file path in Node-Webkit, one that does not involve using ffmpeg.

ffprobe.exe is a large file (30mb) and it seems a bit to much to keep it all when this is the only thing I would need it for.


Solution

  • There is a node module : avprober which is a wrapper around the command line tool avprobe which comes bundled with install of avconv

    It reveals details of given media file like Duration

    ... alternatively, here is some python which uses hachoir to parse media header info ... and it does handle video files (AVI,mp4, etc) to reveal Duration

    import sys
    
    from hachoir_core.cmd_line import unicodeFilename
    from hachoir_core.i18n import getTerminalCharset
    from hachoir_metadata import extractMetadata
    from hachoir_parser import createParser
    
    
    filename = sys.argv[1]
    charset = getTerminalCharset()
    filename, real_filename = unicodeFilename(filename, charset), filename
    parser = createParser(filename, real_filename=real_filename)
    metadata = extractMetadata(parser)
    print("Duration (hh:mm:ss.f): %s" % metadata.get('duration'))