Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-ffmpeg

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-ffmpeg - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

demos/video_watermark.js

2

package.json
{
"name": "js-ffmpeg",
"description": "JS FFMpeg",
"version": "0.0.22",
"version": "0.0.23",
"author": "Ziggeo",

@@ -6,0 +6,0 @@ "repository": "https://github.com/jsonize/js-ffmpeg",

@@ -19,3 +19,3 @@ Scoped.require([

bframes: true,
acodec: ["libfaac", "libfdk_aac", "aac", "libvo_aacenc"],
acodec: ["libfaac", "libfdk_aac", "libvo_aacenc", "aac"],
vcodec: "libx264",

@@ -22,0 +22,0 @@ fmt: "mp4",

@@ -55,3 +55,5 @@ Scoped.require([

watermark_x: 0.95,
watermark_y: 0.95
watermark_y: 0.95,
watermarks: []
}, options);

@@ -62,7 +64,17 @@

});
if (options.watermark) {
options.watermarks.unshift({
watermark: options.watermark,
watermark_size: options.watermark_size,
watermark_x: options.watermark_x,
watermark_y: options.watermark_y
});
}
if (options.normalize_audio)
promises.push(ffmpeg_volume_detect.ffmpeg_volume_detect(files[options.audio_map || files.length - 1], opts));
if (options.watermark)
promises.push(ffprobe_simple.ffprobe_simple(options.watermark, opts));
options.watermarks.forEach(function (wm) {
promises.push(ffprobe_simple.ffprobe_simple(wm.watermark, opts));
}, this);
if (opts.test_ffmpeg)

@@ -77,6 +89,7 @@ promises.push(ffmpeg_test.ffmpeg_test(opts));

var watermarkInfo = null;
if (options.watermark)
watermarkInfo = infos.pop();
var watermarkInfos = [];
options.watermarks.forEach(function () {
watermarkInfos.unshift(infos.pop());
});
var audioNormalizationInfo = null;

@@ -313,8 +326,9 @@ if (options.normalize_audio)

if (watermarkInfo) {
var watermarkFilters = options.watermarks.map(function (watermark, i) {
var watermarkInfo = watermarkInfos[i];
var watermarkMeta = watermarkInfo.image || watermarkInfo.video;
var scaleWidth = watermarkMeta.width;
var scaleHeight = watermarkMeta.height;
var maxWidth = targetWidth * options.watermark_size;
var maxHeight = targetHeight * options.watermark_size;
var maxWidth = targetWidth * watermark.watermark_size;
var maxHeight = targetHeight * watermark.watermark_size;
if (scaleWidth > maxWidth || scaleHeight > maxHeight) {

@@ -325,8 +339,21 @@ var watermarkRatio = maxWidth * scaleHeight >= maxHeight * scaleWidth;

}
var posX = options.watermark_x * (targetWidth - scaleWidth);
var posY = options.watermark_y * (targetHeight - scaleHeight);
var v = vfilters ? vfilters + "[next];[next]": "";
vfilters = "movie=" + options.watermark + "," +
"scale=" + [Math.round(scaleWidth), Math.round(scaleHeight)].join(":") + "[wm];[in]" + v + "[wm]" +
"overlay=" + [Math.round(posX), Math.round(posY)].join(":") + "[out]";
var posX = watermark.watermark_x * (targetWidth - scaleWidth);
var posY = watermark.watermark_y * (targetHeight - scaleHeight);
return [
"[prewm" + i + "];",
"movie=" + watermark.watermark + ",",
"scale=" + [Math.round(scaleWidth), Math.round(scaleHeight)].join(":"),
"[wm" + i + "];",
"[prewm" + i + "][wm" + i + "]",
"overlay=" + [Math.round(posX), Math.round(posY)].join(":")
].join("");
}).join("");
if (watermarkFilters) {
if (vfilters)
vfilters = "[in]" + vfilters + watermarkFilters + "[out]";
else
vfilters = watermarkFilters.substring("[prewm0];".length).replace("[prewm0]", "[in]") + "[out]";
}

@@ -333,0 +360,0 @@

@@ -17,1 +17,23 @@ var ffmpeg = require(__dirname + "/../../index.js");

});
QUnit.test("ffmpeg-simple with double logo", function(assert) {
var done = assert.async();
ffmpeg.ffmpeg_simple(STANDARD_MP4, {
watermarks: [{
watermark: WATERMARK_FILE,
watermark_size: 0.25,
watermark_x: 0.95,
watermark_y: 0.95
}, {
watermark: WATERMARK_FILE,
watermark_size: 0.25,
watermark_x: 0.05,
watermark_y: 0.05
}]
}, TEMP_MP4_VIDEO, null, null, settings).callback(function (error, value) {
assert.ok(!error);
done();
});
});
module.exports = {
test_ffmpeg: true
/*

@@ -3,0 +4,0 @@ test_info: {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc