@vanih/dunes-node
- CompressionOptions
- CutOptions
- FfmpegData
- FfprobeOutput
- Format
- RunFfmpegOptions
- SimpleAnalysisStats
- Stream
- ThumbnailOptions
Ƭ CompressionOptions: { audioBitrateKbs?
: number
; bitrateKbs?
: number
; crf?
: IntRange
<0
, 64
> ; height?
: number
; maxBitrateKbs?
: number
; minBitrateKbs?
: number
; width?
: number
} & RunFfmpegOptions
Ƭ CutOptions: { endTimeMs
: number
; precise?
: boolean
; startTimeMs
: number
} & RunFfmpegOptions
Ƭ FfmpegData: Object
Name | Type |
---|---|
bitrate |
number |
fps |
number |
frame |
number |
q |
number |
rawString |
string |
size |
number |
speed |
number |
time |
number |
Ƭ FfprobeOutput: Object
Name | Type |
---|---|
format |
Format |
streams |
Stream [] |
Ƭ Format: Object
Name | Type |
---|---|
bit_rate |
string |
duration |
string |
filename |
string |
format_long_name |
string |
format_name |
string |
nb_programs |
number |
nb_streams |
number |
probe_score |
number |
size |
string |
start_time |
string |
tags |
{ compatible_brands : string ; encoder : string ; major_brand : string ; minor_version : string } |
tags.compatible_brands |
string |
tags.encoder |
string |
tags.major_brand |
string |
tags.minor_version |
string |
Ƭ RunFfmpegOptions: Object
Name | Type |
---|---|
onProgress? |
(data : FfmpegData ) => void |
onStart? |
(command : string ) => void |
shouldOverwrite? |
boolean |
Ƭ SimpleAnalysisStats: Object
Name | Type |
---|---|
audio? |
{ channels : number ; sampleRate : number } |
audio.channels |
number |
audio.sampleRate |
number |
bitrateKb |
number |
durationMs |
number |
sizeBytes |
number |
video? |
{ fps : number ; height : number ; width : number } |
video.fps |
number |
video.height |
number |
video.width |
number |
Ƭ Stream: Object
Name | Type |
---|---|
avg_frame_rate |
string |
bit_rate |
string |
bits_per_raw_sample? |
string |
bits_per_sample? |
number |
channel_layout? |
string |
channels? |
number |
chroma_location? |
string |
codec_long_name |
string |
codec_name |
string |
codec_tag |
string |
codec_tag_string |
string |
codec_time_base |
string |
codec_type |
string |
coded_height? |
number |
coded_width? |
number |
display_aspect_ratio? |
string |
disposition |
{ attached_pic : number ; clean_effects : number ; comment : number ; default : number ; dub : number ; forced : number ; hearing_impaired : number ; karaoke : number ; lyrics : number ; original : number ; timed_thumbnails : number ; visual_impaired : number } |
disposition.attached_pic |
number |
disposition.clean_effects |
number |
disposition.comment |
number |
disposition.default |
number |
disposition.dub |
number |
disposition.forced |
number |
disposition.hearing_impaired |
number |
disposition.karaoke |
number |
disposition.lyrics |
number |
disposition.original |
number |
disposition.timed_thumbnails |
number |
disposition.visual_impaired |
number |
duration |
string |
duration_ts |
number |
has_b_frames? |
number |
height? |
number |
index |
number |
is_avc? |
string |
level? |
number |
max_bit_rate? |
string |
nal_length_size? |
string |
nb_frames |
string |
pix_fmt? |
string |
profile |
string |
r_frame_rate |
string |
refs? |
number |
sample_aspect_ratio? |
string |
sample_fmt? |
string |
sample_rate? |
string |
start_pts |
number |
start_time |
string |
tags |
{ handler_name : string ; language : string } |
tags.handler_name |
string |
tags.language |
string |
time_base |
string |
width? |
number |
Ƭ ThumbnailOptions: { height
: number
; time?
: number
; width
: number
} & RunFfmpegOptions
▸ analyze(ffprobePath
, path
): Promise
<SimpleAnalysisStats
>
Analyze audio or video file in a simple way.
Name | Type | Description |
---|---|---|
ffprobePath |
string |
- |
path |
string |
Path to video or video file |
Promise
<SimpleAnalysisStats
>
Promise with stats of audio or video file.
▸ compressVideo(ffprobePath
, srcPath
, outPath
, options
): Promise
<void
>
Example
Create compressed copy of video, with the worst possible quality and best size. Resolution is kept original
import { compressVideo } from '@vanih/dunes-node';
const src = './video_in.mp4';
const out = './video_out.webm';
await compressVideo(src, out, {
crf: 63,
});
Throws
When ffmpeg encounters an error
Name | Type | Description |
---|---|---|
ffprobePath |
string |
- |
srcPath |
string |
Path to existing original video |
outPath |
string |
Path where compressed video should be saved. Currently only supports webm files. |
options |
CompressionOptions |
Compression options to use when compressing the video |
Promise
<void
>
Promise that resolves when compression ends.
▸ createThumbnail(ffmpegPath
, srcPath
, outPath
, options
): Promise
<void
>
Throws
When ffmpeg encounters error
Example
Create thumbnail with resolution 32x32
import { createThumbnail } from '@vanih/dunes-node';
const src = './video_in.mp4';
const out = './video_out.webp';
await createThumbnail(src, out, {
width: 32,
height: 32,
});
Name | Type | Description |
---|---|---|
ffmpegPath |
string |
- |
srcPath |
string |
Path to existing original video |
outPath |
string |
Path to webp thumbnail that you want to create |
options |
ThumbnailOptions |
Options for creating thumbnail |
Promise
<void
>
Promise that resolves when thumbnail is created
functions/createThumbnail.ts:27
▸ cut(ffmpegPath
, srcPath
, outPath
, options
): Promise
<void
>
Name | Type |
---|---|
ffmpegPath |
string |
srcPath |
string |
outPath |
string |
options |
CutOptions |
Promise
<void
>