
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ffmpeg-progress
Advanced tools
Extract progress from ffmpeg child_process output stream
npm install ffmpeg-progress
Get video duration:
import { scanVideo } from 'ffmpeg-progress'
console.log(await scanVideo('test/in.mp4'))
// { duration: '00:52:04.78', seconds: 3124.78 }
Convert video and monitor progress:
import { startTimer } from '@beenotung/tslib/timer'
import { convertFile, parseToSeconds } from 'ffmpeg-progress'
let timer = startTimer('estimate duration')
await convertFile({
inFile: 'test/in.mp4',
outFile: 'test/out.mp4',
onDuration(duration) {
timer.next('convert video')
timer.setEstimateProgress(parseToSeconds(duration))
},
onProgress(args) {
timer.tick(args.deltaSeconds)
},
})
timer.end()
Convert video with custom FFmpeg arguments:
import { convertFile } from 'ffmpeg-progress'
// H.264 codec with YUV420p pixel format and 2000k bitrate
await convertFile({
inFile: 'input.mp4',
outFile: 'output.mp4',
ffmpegArgs: ['-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-b:v', '2000k'],
})
// Resize video - Scale to 720p
await convertFile({
inFile: 'input.mp4',
outFile: 'output.mp4',
ffmpegArgs: ['-vf', 'scale=1280:720'],
})
// Extract audio - Convert video to MP3
await convertFile({
inFile: 'input.mp4',
outFile: 'output.mp3',
ffmpegArgs: ['-vn', '-acodec', 'libmp3lame', '-ab', '192k'],
})
// Quality preset - Use H.264 with slow preset and CRF quality
await convertFile({
inFile: 'input.mp4',
outFile: 'output.mp4',
ffmpegArgs: ['-c:v', 'libx264', '-preset', 'slow', '-crf', '23'],
})
Rotate video:
import { rotateVideo } from 'ffmpeg-progress'
await rotateVideo({
inFile: 'test/in.mp4',
outFile: 'test/rotated.mp4',
angle: 90, // Rotate 90° clockwise (or 180, 270)
})
Progress monitoring is also available similar to convertFile using onDuration, onProgress, etc.
Get video resolution:
import { getVideoResolution } from 'ffmpeg-progress'
console.log(await getVideoResolution('test/rotate.mp4'))
// { width: 3024, height: 4032 }
Get video duration in seconds:
import { getVideoDuration } from 'ffmpeg-progress'
console.log(await getVideoDuration('test/in.mp4'))
// 15.04 (duration in seconds)
import { ChildProcessWithoutNullStreams } from 'child_process'
export function parseToSeconds(str: string): number
export function scanVideo(file: string): Promise<ScanVideoResult>
export type ScanVideoResult = {
/** @description e.g. "00:03:00.03" */
duration: string
/** @description e.g. 180.03 */
seconds: number
/** @description e.g. "4032x3024" */
resolution: string
}
export type ProgressArgs = {
onData?: (chunk: Buffer) => void
onDuration?: (duration: string) => void
onTime?: (time: string) => void
onProgress?: (args: OnProgressArgs) => void
}
export type OnProgressArgs = {
deltaSeconds: number
currentSeconds: number
totalSeconds: number
time: string
duration: string
abort: () => void
}
export function convertFile(
args: {
inFile: string
outFile: string
ffmpegArgs?: string[]
} & ProgressArgs,
): Promise<void>
export function rotateVideo(
args: {
inFile: string
outFile: string
/** degrees to rotate in clockwise direction */
angle: 90 | 180 | 270
} & ProgressArgs,
): Promise<void>
export function attachChildProcess(
args: {
childProcess: ChildProcessWithoutNullStreams
} & ProgressArgs,
): Promise<void>
/**
* take a image frame from the video,
* this is more accurate than parsing the resolution string in ffmpeg,
* because the video has rotation metadata.
*/
export function getVideoResolution(video_file: string): Promise<{
width: number
height: number
}>
/** @description get video duration in seconds, e.g. `15.04` */
export async function getVideoDuration(video_file: string): Promise<number>
This project is licensed with BSD-2-Clause
This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:
FAQs
Extract progress from ffmpeg child_process
We found that ffmpeg-progress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.