ffmpeg-progress 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ffmpeg-progress
2
2
 
3
- Extract progress from ffmpeg child_process
3
+ Extract progress from ffmpeg child_process output stream
4
4
 
5
5
  [![npm Package Version](https://img.shields.io/npm/v/ffmpeg-progress)](https://www.npmjs.com/package/ffmpeg-progress)
6
6
 
package/core.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
3
  import { ChildProcessWithoutNullStreams } from 'child_process';
4
- export declare function parseTime(str: string): number;
4
+ export declare function parseToSeconds(str: string): number;
5
5
  export type ScanVideoResult = {
6
6
  duration: string;
7
7
  seconds: number;
package/core.js CHANGED
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachChildProcess = exports.convertFile = exports.scanVideo = exports.parseTime = void 0;
3
+ exports.attachChildProcess = exports.convertFile = exports.scanVideo = exports.parseToSeconds = void 0;
4
4
  const child_process_1 = require("child_process");
5
- function parseTime(str) {
5
+ function parseToSeconds(str) {
6
6
  let parts = str.split(':');
7
7
  let h = +parts[0];
8
8
  let m = +parts[1];
9
9
  let s = +parts[2];
10
10
  return (h * 60 + m) * 60 + s;
11
11
  }
12
- exports.parseTime = parseTime;
12
+ exports.parseToSeconds = parseToSeconds;
13
13
  function scanVideo(file) {
14
14
  return new Promise((resolve, reject) => {
15
15
  (0, child_process_1.exec)(`ffmpeg -i ${JSON.stringify(file)} 2>&1`, (err, stdout, stderr) => {
16
16
  let match = stdout.match(/Duration: ([0-9:.]+),/);
17
17
  if (match) {
18
18
  let duration = match[1];
19
- let seconds = parseTime(duration);
19
+ let seconds = parseToSeconds(duration);
20
20
  resolve({ duration, seconds });
21
21
  return;
22
22
  }
@@ -48,7 +48,7 @@ async function attachChildProcess(args) {
48
48
  let match = str.match(/Duration: ([0-9:.]+),/);
49
49
  if (match) {
50
50
  duration = match[1];
51
- totalSeconds = parseTime(duration);
51
+ totalSeconds = parseToSeconds(duration);
52
52
  if (args.onDuration) {
53
53
  args.onDuration(duration);
54
54
  }
@@ -61,7 +61,7 @@ async function attachChildProcess(args) {
61
61
  args.onTime(time);
62
62
  }
63
63
  if (args.onProgress) {
64
- let currentSeconds = parseTime(time);
64
+ let currentSeconds = parseToSeconds(time);
65
65
  let deltaSeconds = currentSeconds - lastSeconds;
66
66
  lastSeconds = currentSeconds;
67
67
  args.onProgress({
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ffmpeg-progress",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Extract progress from ffmpeg child_process",
5
5
  "keywords": [
6
6
  "ffmpeg",
7
7
  "progress",
8
8
  "child_process",
9
+ "stream",
9
10
  "typescript",
10
11
  "video",
11
12
  "convert",