ffmpeg-progress 1.1.1 → 1.1.2

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.
Files changed (3) hide show
  1. package/core.d.ts +2 -2
  2. package/core.js +4 -1
  3. package/package.json +1 -1
package/core.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ChildProcessWithoutNullStreams } from 'child_process';
2
2
  export declare function parseToSeconds(str: string): number;
3
3
  export type ScanVideoResult = {
4
- /** @description e.g. "00:03:00.03" */
4
+ /** @description e.g. "00:03:00.03" or "N/A" */
5
5
  duration: string;
6
- /** @description e.g. 180.03 */
6
+ /** @description e.g. 180.03 or 0 */
7
7
  seconds: number;
8
8
  /** @description e.g. "4032x3024" */
9
9
  resolution: string;
package/core.js CHANGED
@@ -7,6 +7,8 @@ exports.attachChildProcess = attachChildProcess;
7
7
  exports.estimateOutSize = estimateOutSize;
8
8
  const child_process_1 = require("child_process");
9
9
  function parseToSeconds(str) {
10
+ if (str == 'N/A')
11
+ return NaN;
10
12
  let parts = str.split(':');
11
13
  let h = +parts[0];
12
14
  let m = +parts[1];
@@ -18,7 +20,8 @@ function scanVideo(file) {
18
20
  (0, child_process_1.exec)(`ffmpeg -i ${JSON.stringify(file)} 2>&1`, (err, stdout, stderr) => {
19
21
  try {
20
22
  // e.g. " Duration: 00:03:00.03, start: 0.000000, bitrate: 2234 kb/s"
21
- let match = stdout.match(/Duration: ([0-9:.]+),/);
23
+ // e.g. " Duration: N/A, start: 0.000000, bitrate: N/A"
24
+ let match = stdout.match(/Duration: ([0-9:.]+|N\/A),/);
22
25
  if (!match) {
23
26
  throw new Error('failed to find video duration');
24
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ffmpeg-progress",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Extract progress from ffmpeg child_process",
5
5
  "keywords": [
6
6
  "ffmpeg",