fluent-ffmpeg/node-fluent-ffmpeg

How to record screen on Mac?

Nquq opened this issue · 0 comments

Nquq commented

Version information

  • fluent-ffmpeg version: ^2.1.2
  • ffmpeg version: 6.1.1
  • OS: MacOS Sonoma 14.4.1

Code to reproduce

const { createWriteStream } = require('fs')
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
const ffmpeg = require('fluent-ffmpeg')
ffmpeg.setFfmpegPath(ffmpegPath)

const cropArea = '3600:1980:0:400'
const screenID = 2

const outStream = createWriteStream('../videos/test.mp4')

const stop = movie => {
	return movie.ffmpegProc.stdin.write('q')
}

const recordingProcessVideo = ffmpeg(`${screenID}:1`)
	.inputFormat('avfoundation')
	.videoFilter(`crop=${cropArea}`)
	.format('matroska')
	.on('error', error => console.log(`Encoding Error: ${error.message}`))
	.on('exit', () => console.log('Video recorder exited'))
	.on('close', () => console.log('Video recorder closed'))
	.on('end', () => console.log('Video Transcoding succeeded !'))
	.on('start', () => console.log('Video Transcoding Started !'))
	.on('progress', progress => console.log(progress))

recordingProcessVideo.pipe(outStream, { end: true })

setTimeout(() => {
	stop(recordingProcessVideo)
}, 3000)

1-2 months ago its works fine, but now its dont work. Only 'start' event work. Nothing happend after timeout
image