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

video-cropper

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

video-cropper - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

README.md

64

index.js

@@ -1,6 +0,7 @@

const fs = require('fs');
const moment = require('moment');
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegPath)
#!/usr/bin/env node
const fs = require("fs");
const moment = require("moment");
const ffmpegPath = require("@ffmpeg-installer/ffmpeg").path;
const ffmpeg = require("fluent-ffmpeg");
ffmpeg.setFfmpegPath(ffmpegPath);

@@ -14,33 +15,36 @@ const name = process.argv[2];

if(!fs.existsSync('cut.json')) {
console.log('No config file found. Please provide a file named "cut.json" next to the video you want to cut')
if (!fs.existsSync("cut.json")) {
console.log(
'No config file found. Please provide a file named "cut.json" next to the video you want to cut'
);
return;
}
fs.readFile('cut.json', (err, file) => {
const cutConfig = JSON.parse(file);
fs.readFile("cut.json", (err, file) => {
const cutConfig = JSON.parse(file);
cutConfig.forEach(element => {
if(!element.start || !element.end || !element.name) {
console.log('Wrong config file format. Please provide start, end & name');
return;
}
cutConfig.forEach((element) => {
if (!element.start || !element.end || !element.name) {
console.log("Wrong config file format. Please provide start, end & name");
return;
}
const start = moment(element.start, "HH:mm:ss");
const end = moment(element.end, "HH:mm:ss");
const duration = moment.duration(end.diff(start));
console.log(duration)
const start = moment(element.start, "HH:mm:ss");
const end = moment(element.end, "HH:mm:ss");
const duration = moment.duration(end.diff(start));
ffmpeg(`${name}.mp4`)
.setStartTime(element.start)
.setDuration(duration.asSeconds())
.output(`${element.name}.mp4`)
.on('end', function(err) {
if(!err) { console.log('conversion Done') }
})
.on('error', function(err){
console.log('error: ', err)
}).run()
});
ffmpeg(`${name}.mp4`)
.setStartTime(element.start)
.setDuration(duration.asSeconds())
.output(`${element.name}.mp4`)
.on("end", function (err) {
if (!err) {
console.log("conversion Done");
}
})
.on("error", function (err) {
console.log("error: ", err);
})
.run();
});
});
{
"name": "video-cropper",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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