
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
node-video-lib
Advanced tools
Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer
This library works only with MP4 and FLV video files encoded using H.264/H.265 video codecs and AAC audio codec.
$ npm install node-video-lib
const fs = require('fs');
const VideoLib = require('node-video-lib');
let fd = fs.openSync('/path/to/file', 'r');
try {
let movie = VideoLib.MovieParser.parse(fd);
// Work with movie
console.log('Duration:', movie.relativeDuration());
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fd);
}
const fs = require('fs');
const VideoLib = require('node-video-lib');
let fd = fs.openSync('/path/to/file', 'r');
try {
let movie = VideoLib.MovieParser.parse(fd);
let fragmentList = VideoLib.FragmentListBuilder.build(movie, 5);
for (let i = 0; i < fragmentList.count(); i++) {
let fragment = fragmentList.get(i);
let sampleBuffers = VideoLib.FragmentReader.readSamples(fragment, fd);
let buffer = VideoLib.HLSPacketizer.packetize(fragment, sampleBuffers);
// Now buffer contains MPEG-TS chunk
}
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fd);
}
const fs = require('fs');
const VideoLib = require('node-video-lib');
let fd = fs.openSync('/path/to/file', 'r');
try {
let movie = VideoLib.MovieParser.parse(fd);
let fw = fs.openSync('/path/to/output.mp4', 'w');
try {
VideoLib.MP4Builder.build(movie, fd, fw);
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fw);
}
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fd);
}
const fs = require('fs');
const VideoLib = require('node-video-lib');
let fd = fs.openSync('/path/to/file', 'r');
try {
let movie = VideoLib.MovieParser.parse(fd);
let fragmentList = VideoLib.FragmentListBuilder.build(movie, 5);
console.log('Duration:', fragmentList.relativeDuration());
let fdi = fs.openSync('/path/to/index.idx', 'w');
try {
VideoLib.FragmentListIndexer.index(fragmentList, fdi);
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fdi);
}
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fd);
}
const fs = require('fs');
const VideoLib = require('node-video-lib');
let fd = fs.openSync('/path/to/file', 'r');
let fdi = fs.openSync('/path/to/index.idx', 'r');
try {
let fragmentList = VideoLib.FragmentListIndexer.read(fdi);
console.log('Duration:', fragmentList.relativeDuration());
for (let i = 0; i < fragmentList.count(); i++) {
let fragment = fragmentList.get(i);
let sampleBuffers = VideoLib.FragmentReader.readSamples(fragment, fd);
let buffer = VideoLib.HLSPacketizer.packetize(fragment, sampleBuffers);
// Now buffer contains MPEG-TS chunk
}
} catch (ex) {
console.error('Error:', ex);
} finally {
fs.closeSync(fd);
fs.closeSync(fdi);
}
A tool for parsing video files (MP4 or FLV).
const MovieParser = require('node-video-lib').MovieParser
Methods:
A tool for parsing MP4 video files.
const MP4Parser = require('node-video-lib').MP4Parser
Methods:
A tool for parsing FLV video files.
const FLVParser = require('node-video-lib').FLVParser
Methods:
A tool for building MP4 video files.
const MP4Builder = require('node-video-lib').MP4Builder
Methods:
A tool for creating MPEG-TS chunks.
const HLSPacketizer = require('node-video-lib').HLSPacketizer
Methods:
A tool for splitting the movie into a list of fragments.
const FragmentListBuilder = require('node-video-lib').FragmentListBuilder
Methods:
A tool to work with index files.
const FragmentListIndexer = require('node-video-lib').FragmentListIndexer
Methods:
A tool for reading samples data of the given movie fragment.
const FragmentReader = require('node-video-lib').FragmentReader
Methods:
A movie class
const Movie = require('node-video-lib').Movie
Properties:
Methods:
A list of movie fragments class.
const FragmentList = require('node-video-lib').FragmentList
Properties:
Methods:
A movie fragment class
const Fragment = require('node-video-lib').Fragment
Properties:
Methods:
A general track class
const Track = require('node-video-lib').Track
Properties:
Methods:
An audio track class. Extends the general track class
const AudioTrack = require('node-video-lib').AudioTrack
Properties:
A video track class. Extends the general track class
const VideoTrack = require('node-video-lib').VideoTrack
Properties:
Methods:
A general video sample class
const Sample = require('node-video-lib').Sample
Properties:
Methods:
An audio sample class. Extends the general sample class
const AudioSample = require('node-video-lib').AudioSample
A video sample class. Extends the general sample class
const VideoSample = require('node-video-lib').VideoSample
Properties:
FAQs
Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer
The npm package node-video-lib receives a total of 1,395 weekly downloads. As such, node-video-lib popularity was classified as popular.
We found that node-video-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.