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

fluent-ffmpeg / node-fluent-ffmpeg / 6870338745

14 Nov 2023 10:34PM UTC coverage: 87.695% (-3.1%) from 90.801%
6870338745

Pull #1235

github

web-flow
Merge 29d32a66b into 4e02d1257
Pull Request #1235: V3 experiments

179 of 193 branches covered (0.0%)

898 of 1024 new or added lines in 13 files covered. (87.7%)

898 of 1024 relevant lines covered (87.7%)

5.06 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
export 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
      if (options.inputs) {
×
NEW
19
        throw new Error("Cannot specify both 'input' and 'inputs'")
×
NEW
20
      }
×
NEW
21

×
NEW
22
      options.inputs = [options.input]
×
NEW
23
    }
×
NEW
24

×
NEW
25
    if (options.output) {
×
NEW
26
      if (options.outputs) {
×
NEW
27
        throw new Error("Cannot specify both 'output' and 'outputs'")
×
NEW
28
      }
×
NEW
29

×
NEW
30
      options.outputs = [options.output]
×
NEW
31
    }
×
NEW
32

×
NEW
33
    this.inputs = (options.inputs || []).map(
×
NEW
34
      (inputOptions) => new FfmpegInput(inputOptions)
×
NEW
35
    )
×
NEW
36

×
NEW
37
    this.outputs = (options.outputs || []).map(
×
NEW
38
      (outputOptions) => new FfmpegOutput(outputOptions)
×
NEW
39
    )
×
NEW
40

×
NEW
41
    this.validateIO()
×
NEW
42
  }
×
NEW
43

×
NEW
44
  validateIO(): void {
×
NEW
45
    if (this.inputs.filter((i) => i.isStream).length > 1) {
×
NEW
46
      throw new Error(`At most one stream input is supported`)
×
NEW
47
    }
×
NEW
48

×
NEW
49
    if (this.outputs.filter((o) => o.isStream).length > 1) {
×
NEW
50
      throw new Error(`At most one stream output is supported`)
×
NEW
51
    }
×
NEW
52
  }
×
NEW
53

×
NEW
54
  getFfmpegArguments(): string[] {
×
NEW
55
    let args: string[] = []
×
NEW
56

×
NEW
57
    for (let input of this.inputs) {
×
NEW
58
      args.push(...input.getFfmpegArguments())
×
NEW
59
    }
×
NEW
60

×
NEW
61
    // TODO complex filters
×
NEW
62

×
NEW
63
    if (this.outputs.some((o) => o.isLocalFile)) {
×
NEW
64
      // Force overwrite outputs
×
NEW
65
      args.push('-y')
×
NEW
66
    }
×
NEW
67

×
NEW
68
    for (let output of this.outputs) {
×
NEW
69
      args.push(...output.getFfmpegArguments())
×
NEW
70
    }
×
NEW
71

×
NEW
72
    return args
×
NEW
73
  }
×
NEW
74

×
NEW
75
  run(options: RunOptions): Promise<RunResult> {
×
NEW
76
    let proc = new FfmpegProcess({
×
NEW
77
      args: this.getFfmpegArguments(),
×
NEW
78
      ...options
×
NEW
79
    })
×
NEW
80
    return proc.run()
×
NEW
81
  }
×
NEW
82
}
×
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