ffmpeg-progressbar-cli
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -5,13 +5,13 @@ #!/usr/bin/env node | ||
/** | ||
* The maximum length of the filename label displayed next to the bar. | ||
* The maximum number of characters of the filename label displayed next to the progress bar beam. | ||
* @constant | ||
* @default | ||
*/ | ||
const BAR_FILENAME_LENGTH = process.env.BAR_FILENAME_LENGTH | 20 | ||
const BAR_FILENAME_LENGTH = process.env.BAR_FILENAME_LENGTH || 10 | ||
/** | ||
* The share of horizontal display real estate the bar should occupy. | ||
* The share of (available) horizontal display real estate the progress bar beam should occupy. | ||
* @constant | ||
*/ | ||
const BAR_BAR_SIZE_RATIO = process.env.BAR_BAR_SIZE_RATIO | 0.4 | ||
const BAR_BEAM_RATIO = process.env.BAR_SIZE_RATIO || 0.9 | ||
@@ -44,5 +44,5 @@ | ||
*/ | ||
const progressBar = require(path.join(appRootPath.path, 'lib', 'progress-bar')) | ||
const parseFFmpegLog = require(path.join(appRootPath.path, 'lib', 'parse-ffmpeg-log')) | ||
const utils = require(path.join(appRootPath.path, 'lib', 'utils')) | ||
const progressBar = require('./progress-bar') | ||
const parseFFmpegLog = require('./parse-ffmpeg-log') | ||
const utilities = require('./utilities') | ||
@@ -64,3 +64,23 @@ | ||
/** | ||
* Approximate the available width for the progress bars' beam | ||
* @returns {String} - | ||
*/ | ||
let availableWidthForProgressBarBeam = () => { | ||
// console.debug('availableWidthForProgressBarBeam()') | ||
// TEXT LABEL WIDTH | ||
// 🎬 Rendering 12 | ||
// BAR_FILENAME_LENGTH 10 | ||
// | {percentagePad}% | ETA {etaTimecode} 20 | ||
const totalWidth = windowSize.get().width | ||
const textWidth = 12 + Number(BAR_FILENAME_LENGTH) + 20 | ||
const graceWidth = 4 | ||
return totalWidth - textWidth - graceWidth | ||
} | ||
/** | ||
* Primary Task | ||
@@ -74,3 +94,5 @@ * This task runs the FFmpeg commands provided. | ||
const bar = progressBar({ barsize: Math.floor(windowSize.get().width * BAR_BAR_SIZE_RATIO) }) | ||
const bar = progressBar({ | ||
barsize: Math.floor(availableWidthForProgressBarBeam() * BAR_BEAM_RATIO) | ||
}) | ||
@@ -85,3 +107,5 @@ let didStart = false | ||
if (!didStart) { | ||
bar.start(totalTimeMs, utils.pathToFilenameEllipsis(filePath, BAR_FILENAME_LENGTH)) | ||
bar.start(totalTimeMs, { | ||
filename: utilities.pathToFilenameEllipsis(filePath, BAR_FILENAME_LENGTH) | ||
}) | ||
didStart = true | ||
@@ -88,0 +112,0 @@ } |
@@ -24,3 +24,3 @@ 'use strict' | ||
* @param {String} text - FFmpeg Log Output | ||
* @return {String|void} - First output filepath | ||
* @returns {String|void} - First output filepath | ||
*/ | ||
@@ -43,3 +43,3 @@ let parseFFmpegLogForQuestion = (text) => { | ||
* @param {String} text - FFmpeg Log Output | ||
* @return {Number|void} - Duration (milliseconds) | ||
* @returns {Number|void} - Duration (milliseconds) | ||
*/ | ||
@@ -65,3 +65,3 @@ let parseFFmpegLogForDuration = (text) => { | ||
* @param {String} text - FFmpeg Log Output | ||
* @return {String|void} - First output filepath | ||
* @returns {String|void} - First output filepath | ||
*/ | ||
@@ -68,0 +68,0 @@ let parseFFmpegLogForOutput = (text) => { |
@@ -25,3 +25,2 @@ 'use strict' | ||
/** | ||
@@ -32,4 +31,5 @@ * Modules | ||
*/ | ||
const utils = require(path.join(appRootPath.path, 'lib', 'utils')) | ||
const utilities = require('./utilities') | ||
/** | ||
@@ -45,3 +45,3 @@ * Timecode format | ||
* @param {Number} seconds - Duration in seconds | ||
* @return {String} - Timecode / HH:mm:ss | ||
* @returns {String} - Timecode / HH:mm:ss | ||
*/ | ||
@@ -62,10 +62,10 @@ let convertSecondsToTimecode = (seconds) => { | ||
* Wrapper for progressBar constructor | ||
* @param {Object=} options - Bar configuration options | ||
* @return {CliProgress.Bar} - progressBar | ||
* @param {Object=} userOptions - Options | ||
* @returns {CliProgress.Bar} - progressBar | ||
*/ | ||
let createBar = (options) => { | ||
let createBar = (userOptions) => { | ||
// console.debug('createProgressbar') | ||
const configuration = { | ||
format: `🎬 ${colors.grey('Rendering')} ${colors.green.bold('{filename}')} ${colors.white.bold('|')} ${colors.blue('{bar}')} ${colors.blue.bold('{percentagePad}%')} ${colors.white.bold('|')} ${colors.grey('ETA')} ${colors.red.bold('{etaTimecode}')}`, | ||
const baseOptions = { | ||
format: `🎬 ${colors.grey('Rendering')} ${colors.green.bold('{filename}')} ${colors.white.bold('|')} ${colors.blue('{bar}')} ${colors.blue.bold('{percentagePad}%')} ${colors.white.bold('|')} ${colors.grey('ETA')} ${colors.red.bold('{etaTimecode}')}`, | ||
fps: 20, | ||
@@ -78,3 +78,3 @@ barsize: 60, | ||
stream: process.stdout, | ||
position: 'center', | ||
align: 'center', | ||
stopOnComplete: true, | ||
@@ -84,3 +84,8 @@ clearOnComplete: false | ||
return new CliProgress.Bar(Object.assign(configuration, options), CliProgress.Presets.shades_grey) | ||
const options = Object.assign(baseOptions, userOptions) | ||
// DEBUG | ||
// console.debug('configuration', require('util').inspect(configuration, /** @type {InspectOptions} */ { showHidden: true, colors: true, compact: true })) | ||
return new CliProgress.Bar(options) | ||
} | ||
@@ -90,15 +95,20 @@ | ||
* Wrapper for progressBar.start | ||
* @param {Number} total - Bar total value | ||
* @param {String} filename - Bar filename | ||
* @param {Number} width - Bar width | ||
* @param {Number} totalValue - Total value | ||
* @param {Object=} extraPayload - Extra Payload | ||
* @public | ||
*/ | ||
let startBar = (total, filename, width) => { | ||
let startBar = (totalValue, extraPayload) => { | ||
// console.debug('startProgressbar') | ||
progressBar.start(total, 0, { | ||
const startPayload = { | ||
etaTimecode: convertSecondsToTimecode(0), | ||
fractionToPercentagePadded: '00', | ||
filename: filename | ||
}) | ||
percentagePad: '00' | ||
} | ||
const payload = Object.assign(startPayload, extraPayload) | ||
// DEBUG | ||
// console.debug('startBar', 'payload', require('util').inspect(payload, /** @type {InspectOptions} */ { showHidden: true, colors: true, compact: true })) | ||
progressBar.start(totalValue, 0, payload) | ||
} | ||
@@ -108,13 +118,20 @@ | ||
* Wrapper for progressBar.update | ||
* @param {Number} currentValue - Progress Bar current value | ||
* @param {Number} currentValue - Current value | ||
* @param {Object=} extraPayload - Extra Payload | ||
* @public | ||
*/ | ||
let updateBar = (currentValue) => { | ||
let updateBar = (currentValue, extraPayload) => { | ||
// console.debug('updateProgressbar') | ||
progressBar.update(currentValue, { | ||
etaTimecode: convertSecondsToTimecode(progressBar.eta.eta), | ||
percentagePad: utils.fractionToPercentagePad(progressBar.value / progressBar.total) | ||
}) | ||
const updatePayload = { | ||
percentagePad: utilities.fractionToPercentagePad(progressBar.value / progressBar.total), | ||
etaTimecode: convertSecondsToTimecode(progressBar.eta.eta) | ||
} | ||
const payload = Object.assign(updatePayload, extraPayload) | ||
// DEBUG | ||
// console.debug('updateBar', 'payload', require('util').inspect(payload, /** @type {InspectOptions} */ { showHidden: true, colors: true, compact: true })) | ||
progressBar.update(currentValue, payload) | ||
} | ||
@@ -121,0 +138,0 @@ |
{ | ||
"name": "ffmpeg-progressbar-cli", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A colored progress bar for FFmpeg. Simply use `ffmpeg-bar` instead of `ffmpeg`.", | ||
@@ -37,3 +37,3 @@ "license": "MIT", | ||
"app-root-path": "^2.1.0", | ||
"cli-progress": "git+https://sidneys@github.com/sidneys/Node.CLI-Progress.git#feature/progressbar-position", | ||
"cli-progress": "git+https://github.com/AndiDittrich/Node.CLI-Progress.git#master", | ||
"colors": "^1.3.1", | ||
@@ -44,2 +44,3 @@ "ellipsize": "^0.1.0", | ||
"moment-duration-format": "^2.2.2", | ||
"string-width": "^2.1.1", | ||
"which": "^1.3.1", | ||
@@ -46,0 +47,0 @@ "window-size": "^1.1.1" |
@@ -6,3 +6,3 @@ # ffmpeg-progressbar-cli [![npm](https://img.shields.io/npm/v/ffmpeg-progressbar-cli.svg?style=flat-square)](https://npmjs.com/package/ffmpeg-progressbar-cli) | ||
<b>ffmpeg-progressbar-cli is a <span style="color: red;">c</span><span style="color: orange;">o</span><span style="color: yellow;">l</span><span style="color: green;">o</span><span style="color: blue;">r</span><span style="color: indigo;">e</span><span style="color: violet;">d</span> progress bar for <a href="https://ffmpeg.org">FFmpeg</a>.</b><br> | ||
Simply use <code>ffmpeg-bar</code> instead of <code>ffmpeg</code>!<br><br> | ||
Simply use <code>ffmpeg-bar</code> instead of <code>ffmpeg</code>.<br><br> | ||
</p> | ||
@@ -31,6 +31,10 @@ | ||
The installation process adds the `ffmpeg-bar` binary to your system, which is a fully transparent wrapper for `ffmpeg`, forwarding all commands to FFmpeg as-is. | ||
The installation process adds the `ffmpeg-bar` command to your system. | ||
This is a transparent wrapper, passing all commands to `ffmpeg`. | ||
To use it, simply start `ffmpeg-bar` instead of `ffmpeg`. | ||
To use it, simply launch `ffmpeg-bar` instead of `ffmpeg`, or replace `ffmpeg` with `ffmpeg-bar` inside your scripts. | ||
As long as no errors are encountered, the output of `ffmpeg-bar` will consist of a progress bar, the estimated time until process completion and a percentage. | ||
#### Examples | ||
@@ -58,8 +62,8 @@ | ||
`(default: 20)` The maximum length of the filename label displayed next to the bar. | ||
`(default: 10)` The maximum number of characters of the filename label displayed next to the progress bar beam. | ||
##### `BAR_BAR_SIZE_RATIO ` | ||
##### `BAR_BEAM_RATIO ` | ||
`default: 0.4` | The share of horizontal display real estate the bar should occupy. | ||
`default: 0.9` The share of (available) horizontal display real estate the progress bar beam should occupy. | ||
@@ -66,0 +70,0 @@ #### Examples |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
42794
15
670
105
3
10
+ Addedstring-width@^2.1.1
+ Addedansi-regex@3.0.1(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.0(transitive)
Updatedcli-progress@git+https://github.com/AndiDittrich/Node.CLI-Progress.git#master