mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[@types/ffmpeg] Add types (#35741)
* [@types/ffmpeg]: add types * refactor: make changes as suggested by the linter * fix: restrict to ts 2.1 * refactor: use `export =`
This commit is contained in:
parent
f8b8de8a86
commit
bfa71cfef9
6
types/ffmpeg/ffmpeg-tests.ts
Normal file
6
types/ffmpeg/ffmpeg-tests.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import ffmpeg from 'ffmpeg';
|
||||
|
||||
new ffmpeg('./test/mymovie.avi')
|
||||
.then((video) => {
|
||||
video.setVideoAspectRatio('16:9');
|
||||
});
|
||||
162
types/ffmpeg/index.d.ts
vendored
Normal file
162
types/ffmpeg/index.d.ts
vendored
Normal file
@ -0,0 +1,162 @@
|
||||
// Type definitions for node-ffmpeg 1.0
|
||||
// Project: https://github.com/damianociarla/node-ffmpeg
|
||||
// Definitions by: Prasad Nayak <https://github.com/Buzzertech>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
type WatermarkSettings = Partial<{
|
||||
position: 'NE' | 'NC' | 'NW' | 'SE' | 'SC' | 'SW' | 'C' | 'CE' | 'CW';
|
||||
margin_nord: number;
|
||||
margin_sud: number;
|
||||
margin_east: number;
|
||||
margin_west: number;
|
||||
}>;
|
||||
|
||||
type SaveCallback = (err: Error, files: string) => void;
|
||||
|
||||
type FrameToJPGSettings = Partial<{
|
||||
start_time: string | number;
|
||||
duration_time: string | number;
|
||||
frame_rate: number;
|
||||
size: string;
|
||||
number: number;
|
||||
every_n_frames: number;
|
||||
every_n_seconds: number;
|
||||
every_n_percentage: number;
|
||||
keep_pixel_aspect_ratio: boolean;
|
||||
keep_aspect_ration: boolean;
|
||||
padding_color: string;
|
||||
file_name?: string;
|
||||
}>;
|
||||
|
||||
type StandardVideoMetadata = Partial<{
|
||||
title: string;
|
||||
author: string;
|
||||
album_artist: string;
|
||||
album: string;
|
||||
grouping: string;
|
||||
composer: string;
|
||||
year: string;
|
||||
track: string;
|
||||
comment: string;
|
||||
genre: string;
|
||||
copyright: string;
|
||||
description: string;
|
||||
synopsis: string;
|
||||
show: string;
|
||||
episode_id: string;
|
||||
network: string;
|
||||
lyrics: string;
|
||||
}>;
|
||||
|
||||
type WMVMetadata = Partial<{
|
||||
title: string;
|
||||
author: string;
|
||||
copyright: string;
|
||||
comment: string;
|
||||
rating: string;
|
||||
}>;
|
||||
|
||||
type AVIMetadata = Partial<{
|
||||
IARL: string;
|
||||
IART: string;
|
||||
ICMS: string;
|
||||
ICMT: string;
|
||||
ICOP: string;
|
||||
ICRD: string | Date;
|
||||
ICRP: string;
|
||||
IDIM: string;
|
||||
IDPI: string;
|
||||
IENG: string;
|
||||
IGNR: string;
|
||||
IKEY: string;
|
||||
ILGT: string;
|
||||
ILNG: string;
|
||||
IMED: string;
|
||||
INAM: string;
|
||||
IPLT: string;
|
||||
IPRD: string;
|
||||
ISBJ: string;
|
||||
ISFT: string;
|
||||
ISHP: string;
|
||||
ISRC: string;
|
||||
ISRF: string;
|
||||
ITCH: string;
|
||||
}>;
|
||||
|
||||
type FLVMetadata = Partial<{
|
||||
duration: number;
|
||||
filesize: string;
|
||||
encoder: string;
|
||||
width: number;
|
||||
height: number;
|
||||
videodatarate: number;
|
||||
videocodecid: string;
|
||||
audiodatarate: number;
|
||||
audiosamplerate: number;
|
||||
stereo: boolean;
|
||||
audiocodecid: string;
|
||||
}>;
|
||||
|
||||
interface Video {
|
||||
addCommand(command: string, argument: string): void;
|
||||
addInput(argument: string): void;
|
||||
addFilterComplex(argument: string): void;
|
||||
setOutput(path: string): void;
|
||||
setDisableAudio(): Video;
|
||||
setVideoFormat(format: string): Video;
|
||||
|
||||
setVideoCodec(codec: string): Video;
|
||||
setVideoBitRate(bitrate: number): Video;
|
||||
setVideoFrameRate(framerate: number): Video;
|
||||
|
||||
/**
|
||||
*
|
||||
* @description time in seconds
|
||||
* @example 13
|
||||
*/
|
||||
setVideoStartTime(time: number | string): Video;
|
||||
|
||||
/**
|
||||
*
|
||||
* @example 13
|
||||
*/
|
||||
setVideoDuration(duration: number | string): Video;
|
||||
|
||||
/**
|
||||
*
|
||||
* @example 1.77
|
||||
*/
|
||||
setVideoAspectRatio(aspect: number | string): Video;
|
||||
|
||||
setVideoSize(size: string, keepPixelAspectRatio: boolean, keepAspectRatio: boolean, paddingColor?: string): Video;
|
||||
|
||||
setAudioCodec(codec: string): Video;
|
||||
|
||||
setAudioFrequency(frequency: number): Video;
|
||||
setAudioChannels(channel: number): Video;
|
||||
|
||||
setAudioBitrate(bitrate: number): Video;
|
||||
|
||||
setAudioQuality(quality: number): Video;
|
||||
|
||||
setWatermark(watermarkPath: string, settings: WatermarkSettings): Video;
|
||||
|
||||
save(destinationFileName: string, callback: SaveCallback): void;
|
||||
|
||||
fnExtractSoundToMP3(destinationFileName: string, callback: SaveCallback): void;
|
||||
|
||||
fnExtractFrameToJPG(destinationFolder: string, settings: FrameToJPGSettings, callback: SaveCallback): void;
|
||||
|
||||
fnAddWatermark(watermarkPath: string, newPilePath: string, settings: WatermarkSettings, callback: SaveCallback): void;
|
||||
|
||||
metadata: StandardVideoMetadata & AVIMetadata & FLVMetadata;
|
||||
}
|
||||
|
||||
interface Iffmpeg {
|
||||
new(filePath: string, cb?: (err: Error, video: Video) => void): Promise<Video>;
|
||||
}
|
||||
|
||||
declare var ffmpeg: Iffmpeg;
|
||||
|
||||
export = ffmpeg;
|
||||
25
types/ffmpeg/tsconfig.json
Normal file
25
types/ffmpeg/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ffmpeg-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/ffmpeg/tslint.json
Normal file
1
types/ffmpeg/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user