Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
build(dependencies): Update dependencies (security vulnerability)
Browse files Browse the repository at this point in the history
Update dependences, lodash security patch, cz style commits, fix work
to work with new MAJOR versions of `fast-glob` and `execa`.

re #4
  • Loading branch information
MarcusCemes committed Jul 12, 2019
1 parent 0c07ff0 commit 1267a2b
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 1,072 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,7 @@ We use [SemVer](http://semver.org/) for versioning. For the versions available,
## License

This project is licensed under the **Apache 2.0** License - see the [LICENSE.md](LICENSE.md) file for details

## TODO

- Upgrade "tasker" to the [`dynamic-terminal`](https://github.com/MarcusCemes/dynamic-terminal) package
2 changes: 1 addition & 1 deletion lib/metadata_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MetadataReader {
for (let i = 0; i < this.files.length; i++) {
const file = this.files[i];
try {
const { stdout, stderr } = await execa.shell(`ffprobe -v error -show_format -show_streams -print_format json "${file}"`);
const { stdout, stderr } = await execa(`ffprobe -v error -show_format -show_streams -print_format json "${file}"`);
if (stderr.length === 0) {
const json = JSON.parse(stdout);
transcodeJobs.push({
Expand Down
19 changes: 12 additions & 7 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const chalk = require('chalk');
const fs = require('fs-extra');
const path = require('path');
const fg = require('fast-glob');
const slash = require('slash');

// Others can easily be added, as long as they are supported by FFmpeg
const SUPPORTED_EXTENSIONS = ['mp4', 'm4v', 'mpg', 'mpeg', 'mpv', 'm4v', 'mkv', 'flv', 'wmv', 'avi', 'mts', 'm2ts', 'mov', 'qt'];
Expand Down Expand Up @@ -105,18 +106,22 @@ class Prepare {

let files = [];

// Scan for recognized video files
for (const file of args) {
if (fs.existsSync(file)) {
const p = path.resolve(file);
const stats = fs.statSync(p);
const localDir = slash(path.resolve(file));
const stats = fs.statSync(localDir);
if (stats.isDirectory()) {
const new_files = await fg([path.join(p, '**/*.{' + SUPPORTED_EXTENSIONS.join(',') + '}'), '!' + path.join(p, 'exports/**/*.{' + SUPPORTED_EXTENSIONS.join(',') + '}')]);
const new_files = await fg([
path.posix.join(localDir, '**/*.{' + SUPPORTED_EXTENSIONS.join(',') + '}'),
'!' + path.posix.join(localDir, 'exports/**/*.{' + SUPPORTED_EXTENSIONS.join(',') + '}')
], { absolute: true, onlyFiles: true });
for (const new_file of new_files)
if (!files.includes(new_file))
files.push(new_file);
} else if (stats.isFile()) {
if (!files.includes(p))
files.push(p);
if (!files.includes(localDir))
files.push(localDir);
}
}
task.text = "Found " + files.length + " files";
Expand All @@ -132,8 +137,8 @@ class Prepare {
task.running = false;
task.complete = false;
this.tasker.setState(this.state);
task.text = "Could not scan for files"
throw new Error(err)
task.text = "Could not scan for files";
throw new Error(err);
}
}

Expand Down
41 changes: 18 additions & 23 deletions lib/process_video.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,18 @@ class ProcessVideo {


// Render the first pass
const stderr1 = execa.shell(pass1Arguments).stderr;
await this._readProgress(stderr1, realFramerate * duration); // Pipe into progress reader
const pass1 = execa(pass1Arguments);
this._readProgress(pass1.stderr, realFramerate * duration); // Pipe into progress reader
await pass1;


this.statusData.stage = 2;
this._generateStatus();

// Render the second pass
const stderr2 = execa.shell(pass2Arguments).stderr;
await this._readProgress(stderr2, realFramerate * duration); // Pipe into progress reader

const pass2 = execa(pass2Arguments);
this._readProgress(pass2.stderr, realFramerate * duration); // Pipe into progress reader
await pass2;

// Wait until the output file pops up!
while (!fs.existsSync(`${exportPath}.mp4`)) {
Expand Down Expand Up @@ -236,9 +237,6 @@ class ProcessVideo {
_generateStatus(currentJobCompletion = 0) {

const data = this.statusData;
// console.log(data.job, this.numberJobs, currentJobCompletion, data.stage);
// console.log((currentJobCompletion/2) + (data.stage === 2 ? 0.5 : 0));
// console.log();
const completion = data.job + ((currentJobCompletion/2) + (data.stage === 2 ? 0.5 : 0));

let state = {
Expand Down Expand Up @@ -293,21 +291,18 @@ class ProcessVideo {
* @param {*} totalFrames The total number of frames to render
*/
_readProgress(stream, totalFrames) {
return new Promise(resolve => {
const rl = readline.createInterface({
input: stream,
});
rl.on('line', (input) => {
const regex = /frame=\s*([0-9]+)/g;
const result = regex.exec(input);
if (result && result[1]) {
this._generateStatus(parseInt(result[1]) / totalFrames);
}
});
rl.on('close', (input) => {
rl.close();
resolve();
});
const rl = readline.createInterface({
input: stream,
});
rl.on('line', (input) => {
const regex = /frame=\s*([0-9]+)/g;
const result = regex.exec(input);
if (result && result[1]) {
this._generateStatus(parseInt(result[1]) / totalFrames);
}
});
rl.once('close', () => {
rl.close();
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/transcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Transcode {
fs.ensureDirSync(exportsFolder);
}

console.log();
process.stdout.write("\n");
this.tasker.start();

const efficiencies = [];
Expand Down
Loading

0 comments on commit 1267a2b

Please sign in to comment.