node-video-common
Node.js common video classes
Installation
npm install node-video-common
Classes
Sample
A general video sample class
const Sample = Sample;
Properties:
- buffer <Buffer> - Sample content
- 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>
Audio sample
An audio sample class. Extends the general sample class
const AudioSample = AudioSample;
Video sample
A video sample class. Extends the general sample class
const VideoSample = VideoSample;
Properties:
- compositionOffset <Integer> - Composition offset
- keyframe <Boolean> - Keyframe flag
Track
A general track class
const Track = Track;
Properties:
- duration <Integer> - Track duration
- timescale <Integer> - Track timescale
- extraData <Buffer> - Codec information content
- samples <Array> - List of track samples
Methods:
- relativeDuration() - Track duration in seconds
- Return: <Number>
- addSample(sample) - Add a sample to the samples list
- sample <Sample> - Sample
- createSample() - Create a new sample
- Return: <Sample>
Audio track
An audio track class. Extends the general track class
const AudioTrack = AudioTrack;
Properties:
- channels <Integer> - Number of audio channels
- sampleRate <Integer> - Audio sample rate
- sampleSize <Integer> - Audio sample size
Methods:
- createSample() - Create a new audio sample
- Return: <AudioSample>
Video track
A video track class. Extends the general track class
const AudioTrack = AudioTrack;
Properties:
- width <Integer> - Video width
- height <Integer> - Video height
Methods:
- createSample() - Create a new video sample
- Return: <VideoSample>
Fragment
A movie fragment class
const Fragment = Fragment;
Properties:
- file <Integer> - File descriptor
- timestamp <Integer> - Fragment timestamp
- duration <Integer> - Fragment duration
- timescale <Integer> - Fragment timescale
- videoExtraData <Buffer> - Video codec information content
- audioExtraData <Buffer> - Audio codec information content
- samples <Array> - List of fragment samples
Methods:
- relativeTimestamp() - Fragment timestamp in seconds
- Return: <Number>
- relativeDuration() - Fragment duration in seconds
- Return: <Number>
- addSample(sample) - Add a sample to the samples list
- sample <Sample> - Sample
- readSamples() - Read samples content
Movie
A movie class
const Movie = Movie;
Properties:
- file <Integer> - File descriptor
- duration <Integer> - Fragment duration
- timescale <Integer> - Fragment timescale
- tracks <Array> - List of movie tracks
Methods:
- relativeDuration() - Movie duration in seconds
- Return: <Number>
- 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>
- fragments(fragmentDuration) - Split the movie to a list of fragments with an appropriate duration
- fragmentDuration <Integer> - Fragment duration
- Return: <Array>