node-video-lib alternatives and similar modules
Based on the "Miscellaneous" category.
Alternatively, view node-video-lib alternatives based on common mentions on social networks and blogs.
-
Electron
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS -
cheerio
The fast, flexible, and elegant library for parsing and manipulating HTML and XML. -
jsdom
A JavaScript implementation of various web standards, for use with Node.js -
v86
x86 virtualization in your browser, recompiling x86 to wasm on the fly -
dotenv
Loads environment variables from .env for nodejs projects. -
patch-package
Fix broken node modules instantly ๐๐ฝโโ๏ธ๐จ -
ssh2
SSH2 client and server modules written in pure JavaScript for node.js -
hypernova
A service for server-side rendering your JavaScript views -
file-type
Detect the file type of a Buffer/Uint8Array/ArrayBuffer -
webworker-threads
Lightweight Web Worker API implementation with native threads -
node-pre-gyp
Node.js tool for easy binary deployment of C++ addons -
Bottleneck
Job scheduler and rate limiter, supports Clustering -
mem
Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input -
hasha
Hashing made simple. Get the hash of a buffer/string/stream/file. -
dot-prop
Get, set, or delete a property from a nested object using a dot path -
basic-ftp
FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript. -
node-bell
Real-time anomalies detection for periodic time series. -
schemapack
Create a schema object to encode/decode your JSON in to a compact byte buffer with no overhead. -
nar
node.js application archive - create self-contained binary like executable applications that are ready to ship and run -
stringify-object
Stringify an object/array like JSON.stringify just without all the double-quotes -
cashify
๐ธ Lightweight currency conversion library, successor of money.js -
require-uncached
Import a module while bypassing the cache -
resolve-from
Resolve the path of a module like require.resolve() but from a given path -
remote-git-tags
Get tags from a remote git repo. Using only JS. No git binary required.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of node-video-lib or a related project?
README
node-video-lib
Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer
Limitations
This library works only with MP4 and FLV video files encoded using H.264/H.265 video codecs and AAC audio codec.
Installation
$ npm install node-video-lib
Usage
Parse video file
const fs = require('fs');
const VideoLib = require('node-video-lib');
fs.open('/path/to/file', 'r', function(err, fd) {
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);
}
});
Create MPEG-TS chunks
const fs = require('fs');
const VideoLib = require('node-video-lib');
fs.open('/path/to/file', 'r', function(err, fd) {
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);
}
});
Build MP4 file
const fs = require('fs');
const VideoLib = require('node-video-lib');
fs.open('/path/to/file', 'r', function(err, fd) {
try {
let movie = VideoLib.MovieParser.parse(fd);
fs.open('/path/to/output.mp4', 'w', function(err, fw) {
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);
}
});
Create index file
const fs = require('fs');
const VideoLib = require('node-video-lib');
fs.open('/path/to/file', 'r', function(err, fd) {
try {
let movie = VideoLib.MovieParser.parse(fd);
let fragmentList = VideoLib.FragmentListBuilder.build(movie, 5);
console.log('Duration:', fragmentList.relativeDuration());
fs.open('/path/to/index.idx', 'w', function(err, fdi) {
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);
}
});
Create MPEG-TS chunks using index file
const fs = require('fs');
const VideoLib = require('node-video-lib');
fs.open('/path/to/file', 'r', function(err, fd) {
fs.open('/path/to/index.idx', 'r', function(err, fdi) {
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);
}
});
});
Classes
MovieParser
A tool for parsing video files (MP4 or FLV).
const MovieParser = require('node-video-lib').MovieParser
Methods:
- parse(source) - Parse video file
MP4Parser
A tool for parsing MP4 video files.
const MP4Parser = require('node-video-lib').MP4Parser
Methods:
- parse(source) - Parse MP4 file
- check(buffer) - Check MP4 header
- buffer <Buffer> - File header (first 8 bytes)
- Return: <boolean>
FLVParser
A tool for parsing FLV video files.
const FLVParser = require('node-video-lib').FLVParser
Methods:
- parse(source) - Parse FLV file
- check(buffer) - Check FLV header
- buffer <Buffer> - File header (first 8 bytes)
- Return: <boolean>
MP4Builder
A tool for building MP4 video files.
const MP4Builder = require('node-video-lib').MP4Builder
Methods:
- build(movie, source, fd) - Build MP4 file
HLSPacketizer
A tool for creating MPEG-TS chunks.
const HLSPacketizer = require('node-video-lib').HLSPacketizer
Methods:
- packetize(fragment, sampleBuffers) - Create MPEG-TS chunk from movie fragment
- fragment <Fragment> - Movie fragment
- sampleBuffers <Array> - Array of buffers
- Return: <Buffer>
FragmentListBuilder
A tool for splitting the movie into a list of fragments.
const FragmentListBuilder = require('node-video-lib').FragmentListBuilder
Methods:
- build(movie, fragmentDuration) - Split the movie to a list of fragments with an appropriate duration
- movie <Movie> - Movie
- fragmentDuration <Integer> - Fragment duration
- Return: <FragmentList>
FragmentListIndexer
A tool to work with index files.
const FragmentListIndexer = require('node-video-lib').FragmentListIndexer
Methods:
- index(fragmentList, fd) - Index fragment list
- fragmentList <FragmentList> - Fragment list
- fd <Integer> - File descriptor
- read(fd) - Read fragment list from index
- fd <Integer> - File descriptor
- Return: <FragmentList>
FragmentReader
A tool for reading samples data of the given movie fragment.
const FragmentReader = require('node-video-lib').FragmentReader
Methods:
- readSamples(fragment, source) - Read samples data
- fragment <Fragment> - Movie fragment
- source <Integer>|<Buffer> - Source (File descriptor or Buffer)
- Return: <Array> Array of buffers
Movie
A movie class
const Movie = require('node-video-lib').Movie
Properties:
- duration <Integer> - Movie duration
- timescale <Integer> - Movie timescale
- tracks <Array> - List of movie tracks
Methods:
- relativeDuration() - Movie duration in seconds
- Return: <Number>
- resolution() - Video resolution
- Return: <String>
- size() - Samples size
- Return: <Integer>
- addTrack(track) - Add a track to the tracks list
- track <Track> - Track
- videoTrack() - Get the first video track
- Return: <VideoTrack>
- audioTrack() - Get the first audio track
- Return: <AudioTrack>
- samples() - Get a list of movie samples ordered by relative timestamp
- Return: <Array>
- ensureDuration() - Calculate and set duration based on the track durations (only if duration is zero)
- Return: <Number>
FragmentList
A list of movie fragments class.
const FragmentList = require('node-video-lib').FragmentList
Properties:
- fragmentDuration <Integer> - Target fragment duration
- duration <Integer> - Movie duration
- timescale <Integer> - Movie timescale
- video <Object> - Video info
- timescale <Integer> - Video timescale
- codec <String> - Codec string
- extraData <Buffer> - Video codec information
- size <Integer> - Video samples size
- width <Integer> - Video width
- height <Integer> - Video height
- audio <Object> - Audio info
- timescale <Integer> - Audio timescale
- codec <String> - Codec string
- extraData <Buffer> - Audio codec information
- size <Integer> - Audio samples size
Methods:
- relativeDuration() - Movie duration in seconds
- Return: <Number>
- count() - Fragments count
- Return: <Integer>
- size() - Samples size
- Return: <Integer>
- get(index) - Get fragment by index
- Return: <Fragment>
Fragment
A movie fragment class
const Fragment = require('node-video-lib').Fragment
Properties:
- timestamp <Integer> - Fragment timestamp
- duration <Integer> - Fragment duration
- timescale <Integer> - Fragment timescale
- videoExtraData <Buffer> - Video codec information
- audioExtraData <Buffer> - Audio codec information
- samples <Array> - List of fragment samples
Methods:
- relativeTimestamp() - Fragment timestamp in seconds
- Return: <Number>
- relativeDuration() - Fragment duration in seconds
- Return: <Number>
- hasVideo() - Fragment has a video track
- Return: <Boolean>
- hasAudio() - Fragment has an audio track
- Return: <Boolean>
Track
A general track class
const Track = require('node-video-lib').Track
Properties:
- duration <Integer> - Track duration
- timescale <Integer> - Track timescale
- codec <String> - Codec string
- extraData <Buffer> - Codec information
- samples <Array> - List of track samples
Methods:
- relativeDuration() - Track duration in seconds
- Return: <Number>
- ensureDuration() - Calculate and set duration based on the sample durations (only if duration is zero)
- Return: <Number>
- size() - Samples size
- Return: <Integer>
AudioTrack
An audio track class. Extends the general track class
const AudioTrack = require('node-video-lib').AudioTrack
Properties:
- channels <Integer> - Number of audio channels
- sampleRate <Integer> - Audio sample rate
- sampleSize <Integer> - Audio sample size
VideoTrack
A video track class. Extends the general track class
const VideoTrack = require('node-video-lib').VideoTrack
Properties:
- width <Integer> - Video width
- height <Integer> - Video height
Methods:
- resolution() - Video resolution
- Return: <String>
Sample
A general video sample class
const Sample = require('node-video-lib').Sample
Properties:
- timestamp <Integer> - Sample timestamp
- timescale <Integer> - Sample timescale
- size <Integer> - Sample size
- offset <Integer> - Sample offset in the file
Methods:
- relativeTimestamp() - Sample timestamp in seconds
- Return: <Number>
AudioSample
An audio sample class. Extends the general sample class
const AudioSample = require('node-video-lib').AudioSample
VideoSample
A video sample class. Extends the general sample class
const VideoSample = require('node-video-lib').VideoSample
Properties:
- compositionOffset <Integer> - Composition offset
- keyframe <Boolean> - Keyframe flag
*Note that all licence references and agreements mentioned in the node-video-lib README section above
are relevant to that project's source code only.