• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fluent-ffmpeg / node-fluent-ffmpeg / 6854001414

13 Nov 2023 06:12PM UTC coverage: 57.495% (-33.3%) from 90.801%
6854001414

Pull #1235

github

web-flow
Merge b730f9a82 into b09261585
Pull Request #1235: V3 experiments

109 of 114 branches covered (0.0%)

560 of 974 new or added lines in 11 files covered. (57.49%)

560 of 974 relevant lines covered (57.49%)

1.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/command.ts
NEW
1
import { FfmpegInput, InputOptions } from './input'
×
NEW
2
import { FfmpegOutput, OutputOptions } from './output'
×
NEW
3
import { FfmpegProcess, RunResult, RunOptions } from './process'
×
NEW
4

×
NEW
5
type CommandOptions = {
×
NEW
6
  input?: InputOptions
×
NEW
7
  inputs?: InputOptions[]
×
NEW
8
  output?: OutputOptions
×
NEW
9
  outputs?: OutputOptions[]
×
NEW
10
}
×
NEW
11

×
NEW
12
export class FfmpegCommand implements CommandOptions {
×
NEW
13
  inputs: FfmpegInput[]
×
NEW
14
  outputs: FfmpegOutput[]
×
NEW
15

×
NEW
16
  constructor(options: CommandOptions) {
×
NEW
17
    if (options.input) {
×
NEW
18
      options.inputs = [options.input]
×
NEW
19
    }
×
NEW
20

×
NEW
21
    if (options.output) {
×
NEW
22
      options.outputs = [options.output]
×
NEW
23
    }
×
NEW
24

×
NEW
25
    this.inputs = (options.inputs || []).map(
×
NEW
26
      (inputOptions) => new FfmpegInput(inputOptions)
×
NEW
27
    )
×
NEW
28
    this.outputs = (options.outputs || []).map(
×
NEW
29
      (outputOptions) => new FfmpegOutput(outputOptions)
×
NEW
30
    )
×
NEW
31

×
NEW
32
    this.validateIO()
×
NEW
33
  }
×
NEW
34

×
NEW
35
  validateIO(): void {
×
NEW
36
    if (this.inputs.filter((i) => i.isStream).length > 1) {
×
NEW
37
      throw new Error(`At most one stream input is supported`)
×
NEW
38
    }
×
NEW
39

×
NEW
40
    if (this.outputs.filter((o) => o.isStream).length > 1) {
×
NEW
41
      throw new Error(`At most one stream output is supported`)
×
NEW
42
    }
×
NEW
43
  }
×
NEW
44

×
NEW
45
  getFfmpegArguments(): string[] {
×
NEW
46
    let args: string[] = []
×
NEW
47

×
NEW
48
    for (let input of this.inputs) {
×
NEW
49
      args.push(...input.getFfmpegArguments())
×
NEW
50
    }
×
NEW
51

×
NEW
52
    // TODO complex filters
×
NEW
53

×
NEW
54
    if (this.outputs.some((o) => o.isLocalFile)) {
×
NEW
55
      // Force overwrite outputs
×
NEW
56
      args.push('-y')
×
NEW
57
    }
×
NEW
58

×
NEW
59
    for (let output of this.outputs) {
×
NEW
60
      args.push(...output.getFfmpegArguments())
×
NEW
61
    }
×
NEW
62

×
NEW
63
    return args
×
NEW
64
  }
×
NEW
65

×
NEW
66
  run(options: RunOptions): Promise<RunResult> {
×
NEW
67
    let proc = new FfmpegProcess({
×
NEW
68
      args: this.getFfmpegArguments(),
×
NEW
69
      ...options
×
NEW
70
    })
×
NEW
71
    return proc.run()
×
NEW
72
  }
×
NEW
73
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc