Socket
Socket
Sign inDemoInstall

canvas-recorder

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-recorder - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

74

bin/index.js

@@ -12,5 +12,42 @@ #! /usr/bin/env node

.option( "-r, --fps <num>", "The framerate at which the sequence should play. Default is 30." )
.option( "-k, --format <format>", "The file format generated: mp4 or gif. Default is mp4" )
.parse( process.argv );
function valueOrDefault( name, defaultValue, restrictions ) {
const value = program[ name ];
if ( !value ) {
return defaultValue;
}
if ( restrictions && restrictions.indexOf( value ) < 0 ) {
throw new Error( name + ' has to be one of: ' + restrictions.join ( ', ' ) );
}
return value;
}
function getCommand( options ) {
switch ( options.format ) {
case "mp4":
return [
`-framerate ${ options.fps }`,
"-i %06d.png",
"-c:v libx264",
"-pix_fmt yuv420p",
options.output,
];
case "gif":
return [
"-f image2",
`-framerate ${ options.fps }`,
"-i %06d.png",
`-r ${ options.fps }`,
options.output,
];
default:
return [];
}
}
exec( "ffmpeg -version", function( error, stdout, stderr ) {

@@ -26,18 +63,29 @@ if ( error || stderr ) {

const fps = program.fps || 30;
const output = program.output || "out.mp4";
const input = program.input || ".";
const options = {};
spawn( "ffmpeg", [
"-i %06d.png",
`-framerate ${ fps }`,
`-r ${ fps }`,
"-c:v libx264",
`-vf "fps=${ fps },format=yuv420p"`,
output,
], {
try {
options.format = valueOrDefault( "format", "mp4", [ "mp4", "gif" ] );
options.fps = valueOrDefault( "fps", 30 );
options.output = valueOrDefault( "output", "out." + options.format );
options.input = valueOrDefault( "input", "." );
} catch( error ) {
console.error( error.message );
return;
}
const spawnOptions = {
stdio: "inherit",
shell: true,
cwd: input,
} );
cwd: options.input,
}
const spawnFlags = getCommand( options );
if ( !spawnFlags ) {
console.error( "Something went wrong. canvas-recorder didn't understand the command." );
return;
}
spawn( "ffmpeg", spawnFlags, spawnOptions );
} );

@@ -0,0 +0,0 @@ import { BaseRecorder, Settings } from "./shared";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /// <reference types="jszip" />

@@ -0,0 +0,0 @@ "use strict";

2

package.json
{
"name": "canvas-recorder",
"version": "1.4.1",
"version": "1.5.0",
"description": "Browserside tool to record canvas animations frame by frame.",

@@ -5,0 +5,0 @@ "types": "./",

# Canvas Recorder
> A blatant ripoff of [Looper](https://github.com/spite/looper)
> A blatant ripoff of [Looper](https://github.com/spite/looper) 😎

@@ -220,2 +220,2 @@ This is a small utility to record a canvas based animation of any sort. The tool can be used to

}
```
```

@@ -0,0 +0,0 @@ /// <reference types="jszip" />

@@ -0,0 +0,0 @@ "use strict";

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