Commit 252043ce authored by Jan Göttlich's avatar Jan Göttlich

as requested change of origin to regiolab
parent c21cd942
File added
# See https://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/playground/tmp/*
# dependencies
/node_modules
/bower_components
# misc
/.sass-cache
/connect.lock
/coverage/*
/tests
/bower_components
/libpeerconnection.log
npm-debug.log*
testem.log
.meteor/local .meteor/local
.meteor/meteorite .meteor/meteorite
# Video thumbnails + WebVTT using Node.js npm # Video thumbnails + WebVTT using Node.js
Thumbnails generator module. Uses [WebVTT](http://dev.w3.org/html5/webvtt/) as thumbnails descriptor. Can pack thumbnails into spritesheet using [node-sprit]() module. Thumbnails generator module. Uses [WebVTT](http://dev.w3.org/html5/webvtt/) as thumbnails descriptor. Can pack thumbnails into spritesheet using [node-sprit]() module.
......
...@@ -56,12 +56,10 @@ module.exports = function(source, options, callback) { ...@@ -56,12 +56,10 @@ module.exports = function(source, options, callback) {
} }
metadata = data metadata = data
if (!options.timemarks) { if (!options.timemarks) {
options.timemarks = [] options.timemarks = []
} }
options.bounds = [] options.bounds = []
var mark var mark
, i = 0 , i = 0
...@@ -105,7 +103,6 @@ module.exports = function(source, options, callback) { ...@@ -105,7 +103,6 @@ module.exports = function(source, options, callback) {
mark += options.framesPerThumbnail / metadata.fps mark += options.framesPerThumbnail / metadata.fps
} }
} }
if (!options.size) { if (!options.size) {
options.size = { options.size = {
width: metadata.width, width: metadata.width,
......
...@@ -22,12 +22,14 @@ var FFmpeg = require('fluent-ffmpeg') ...@@ -22,12 +22,14 @@ var FFmpeg = require('fluent-ffmpeg')
* @param {thumbnailsCallback} callback Accepts arguments: (err, filenames) * @param {thumbnailsCallback} callback Accepts arguments: (err, filenames)
*/ */
exports.generateThumbnails = function(source, options, callback) { exports.generateThumbnails = function(source, options, callback) {
new FFmpeg({source: source}) let mysize = toSizeString(options.size);
.withSize(toSizeString(options.size)) console.log(mysize);
new FFmpeg(source)
.on('error', onerror) .on('error', onerror)
.on('end', success) .on('end', success)
.takeScreenshots( .screenshots(
{ {
size: mysize,
count: options.timemarks.length, count: options.timemarks.length,
timemarks: options.timemarks timemarks: options.timemarks
}, },
...@@ -100,7 +102,7 @@ exports.metadata = function(source, callback) { ...@@ -100,7 +102,7 @@ exports.metadata = function(source, callback) {
* @returns {string} * @returns {string}
*/ */
function toSizeString(dimensions) { function toSizeString(dimensions) {
return dimensions.width + 'x' + dimensions.height return dimensions.width + 'x' + Math.round(dimensions.height)
} }
exports.toSizeString = toSizeString exports.toSizeString = toSizeString
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
"url": "https://github.com/estliberitas/node-thumbnails-webvtt/issues" "url": "https://github.com/estliberitas/node-thumbnails-webvtt/issues"
}, },
"dependencies": { "dependencies": {
"fluent-ffmpeg": "^1.7.2", "fluent-ffmpeg": "^2.1.2",
"fs-extra": "^0.10.0", "fs-extra": "^4.0.1",
"lodash": "^2.4.1", "lodash": "^4.17.4",
"moment": "^2.7.0", "moment": "^2.7.0",
"node-sprite": "^0.1.2" "node-sprite": "^0.1.2"
}, },
......
'use strict';
let thumbgen = require('../lib/index');
thumbgen('./tmp/oceans.mp4', {
output: './tmp/vtt/myVTT.vtt',
size: {
width: 100
},
numThumbnails: 6,
spritesheet: true
}, function(err, metadata) {
if (err) {
console.error(err);
throw err
}
console.log(metadata)
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment