How to use node-video-lib - 9 common examples

To help you get started, we’ve selected a few node-video-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gkozlenko / node-media-server / components / movie.js View on Github external
]).then(() => {
            if (req.fragmentList === null) {
                let movie = VideoLib.MovieParser.parse(req.file);
                req.fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
            }
            next();
        }).finally(() => {
            return Promise.all([req.file, req.index].map((file) => {
github gkozlenko / node-media-server / components / indexer.js View on Github external
static index(name) {
        let fileName = path.join(config.mediaPath, name);
        let indexName = Indexer.getIndexName(name);
        let tmpName = Indexer.getTempName(name);

        let file = null;
        let index = null;

        try {
            file = fs.openSync(fileName, 'r');
            index = fs.openSync(tmpName, 'w');
            let movie = VideoLib.MovieParser.parse(file);
            let fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
            VideoLib.FragmentListIndexer.index(fragmentList, index);
        } finally {
            if (file !== null) {
                fs.closeSync(file);
            }
            if (index !== null) {
                fs.closeSync(index);
            }
        }

        if (fs.existsSync(tmpName)) {
            try {
                Indexer.makeDirs(path.dirname(indexName));
                fs.renameSync(tmpName, indexName);
            } catch (ex) {
                fs.unlinkSync(tmpName);
github gkozlenko / node-media-server / components / indexer.js View on Github external
static index(name) {
        let fileName = path.join(config.mediaPath, name);
        let indexName = Indexer.getIndexName(name);
        let tmpName = Indexer.getTempName(name);

        let file = null;
        let index = null;

        try {
            file = fs.openSync(fileName, 'r');
            index = fs.openSync(tmpName, 'w');
            let movie = VideoLib.MovieParser.parse(file);
            let fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
            VideoLib.FragmentListIndexer.index(fragmentList, index);
        } finally {
            if (file !== null) {
                fs.closeSync(file);
            }
            if (index !== null) {
                fs.closeSync(index);
            }
        }

        if (fs.existsSync(tmpName)) {
            try {
                Indexer.makeDirs(path.dirname(indexName));
                fs.renameSync(tmpName, indexName);
            } catch (ex) {
                fs.unlinkSync(tmpName);
                throw ex;
github gkozlenko / node-media-server / components / movie.js View on Github external
fs.openAsync(indexName, 'r').then((fd) => {
                req.index = fd;
                req.fragmentList = VideoLib.FragmentListIndexer.read(req.index);
            }).catch((err) => {
                let promise = Promise.resolve();
github gkozlenko / node-media-server / components / movie.js View on Github external
]).then(() => {
            if (req.fragmentList === null) {
                let movie = VideoLib.MovieParser.parse(req.file);
                req.fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
            }
            next();
        }).finally(() => {
            return Promise.all([req.file, req.index].map((file) => {
github gkozlenko / node-media-server / components / indexer.js View on Github external
static index(name) {
        let fileName = path.join(config.mediaPath, name);
        let indexName = Indexer.getIndexName(name);
        let tmpName = Indexer.getTempName(name);

        let file = null;
        let index = null;

        try {
            file = fs.openSync(fileName, 'r');
            index = fs.openSync(tmpName, 'w');
            let movie = VideoLib.MovieParser.parse(file);
            let fragmentList = VideoLib.FragmentListBuilder.build(movie, config.fragmentDuration);
            VideoLib.FragmentListIndexer.index(fragmentList, index);
        } finally {
            if (file !== null) {
                fs.closeSync(file);
            }
            if (index !== null) {
                fs.closeSync(index);
            }
        }

        if (fs.existsSync(tmpName)) {
            try {
                Indexer.makeDirs(path.dirname(indexName));
                fs.renameSync(tmpName, indexName);
            } catch (ex) {
github gkozlenko / node-media-server / routes / vod / dash.js View on Github external
router.get(/^(.*)\/(audio|video)\.sidx/, Movie.openMovie, (req, res) => {
    let type = req.params[1];
    req.logger.info('Type:', type);
    let buffer = VideoLib.DASHPacketizer[`${type}Index`](req.fragmentList);
    res.send(buffer);
});
github gkozlenko / node-media-server / routes / vod / hls.js View on Github external
router.get(/^(.*)\/media-(\d+)\.ts$/, Movie.openMovie, (req, res) => {
    let index = parseInt(req.params[1], 10);
    if (req.fragmentList.count() < index) {
        throw new errors.NotFoundError('Chunk Not Found');
    }
    let fragment = req.fragmentList.get(index - 1);
    let sampleBuffers = VideoLib.FragmentReader.readSamples(fragment, req.file);
    let buffer = VideoLib.HLSPacketizer.packetize(fragment, sampleBuffers);
    res.header('Content-Type', 'video/MP2T');
    if (config.drmEnabled) {
        res.send(Movie.encryptChunk(req.params[0], buffer));
    } else {
        res.send(buffer);
    }
});
github gkozlenko / node-media-server / routes / vod / hls.js View on Github external
router.get(/^(.*)\/media-(\d+)\.ts$/, Movie.openMovie, (req, res) => {
    let index = parseInt(req.params[1], 10);
    if (req.fragmentList.count() < index) {
        throw new errors.NotFoundError('Chunk Not Found');
    }
    let fragment = req.fragmentList.get(index - 1);
    let sampleBuffers = VideoLib.FragmentReader.readSamples(fragment, req.file);
    let buffer = VideoLib.HLSPacketizer.packetize(fragment, sampleBuffers);
    res.header('Content-Type', 'video/MP2T');
    if (config.drmEnabled) {
        res.send(Movie.encryptChunk(req.params[0], buffer));
    } else {
        res.send(buffer);
    }
});

node-video-lib

Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer

MIT
Latest version published 7 months ago

Package Health Score

59 / 100
Full package analysis