ffmpeg-node-capture
v1.1.72
Published
Node package with ffmpeg bindings.
Downloads
4
Readme
Node package with ffmpeg bindings.
Note
- Add
#define AUDIO_MIX_DEV
macro insrc/FFmpefCaptureWrapper.h#L25
into theAudio Mix Dev
mode, otherwise cancel! - crop 裁剪的尺寸中 width 和 height 必须都是 16 的倍数(mac要求,win待测试)
- crop 裁剪的尺寸
- 对于 windows 版, width 和 height 必须是 4 的倍数, 以左上为O点,向右为x轴正方向,向下为y轴正方向
- 对于 mac 版 , width 和 height,必须是 16 的倍数,以左下为O点,向右为x轴正方向,向上为y轴正方向(已在代码中转换为和windows一致等坐标系)
Dependency
- Node >= 7.0.0
- node-gyp
- sudo npm install node-gyp
- Virtual device driver
- screencapturer for windows
cd drivers/screencapturer ./install.bat
- Soundflower-2-0b2.dmg for OSX
cd drivers/soundflower && bash ./install.sh
- open "Audio MIDI Setup"
- http://www.jianshu.com/p/a8ff665285de
Compile
cd /path/to/ffmpeg-node-capture
node-gyp configure
node-gyp build
# publish
npm version patch
npm publish
git push
#http://192.168.0.113:4873/#/
#在这里看ffmpeg-node-capture已经1.0.10,就说明好了
Features
- Capture Webcam.
- Capture Display.
- Overlay display and webcam.
- Capture Microphone.
- Capture System Sound.
Basic Usage
const ffmpegCapture = require('ffmpeg-node-capture');
const attached = ffmpegCapture.Display.attach();
ffplay -f rawvideo -pixel_format yuv420p -video_size 1024x768 -i display-1024x768.yuv
ffmpeg -hide_banner -f avfoundation -list_devices true -i ""
Options
- outputWidth: 320
- outputHeight: 240
- mode: 'webcam'
- framerate: 15
- webcam
- deviceName: "",
- deviceIndex: 0,
- pixelFormat: "",
- framerate: 15,
- width: "",
- height: ""
- forceDisplayRatio: false
- display
- offsetX: 0,
- offsetY: 0,
- cropWidth: 0,
- cropHeight: 0,
- scaleFactor: 1 // can not greater than 1.
- displayIndex: 0
- framerate: 15,
- pixelFormat: ""
- width: "",
- height: "",
- captureCursor: false,
- captureClick: false // mac only.
- forceDisplayRatio: false
- overlay
- webcamX:
- webcamY:
- webcamWidth:
- webcamHeight:
API
FFmpegCaptureWrapper.listWebcam()
: list all webcams, and their capability.
[
{"name": "", "capabilities": [{maxFramerate: 30, minFramerate: 15, width: 320, height: 240, pixelFormat: "yuyv422"} ...]}
]
FFmpegCaptureWrapper.listDisplay()
: list all displays, and their capability.
[
{"name": "", "capabilities": [{width: 320, height: 240, pixelFormat: "yuyv422"} ...]}
]
new FFmpegCaptureWrapper():
create a ffmpeg capture stream.
stream.open([options]):
open capture stream.
stream.close():
close capture stream.
stream.update([options]):
update options.
open
event (data, width, height):
emit when stream opened successfully.
error
event (err) :
emit when something wrong.
close
event:
emit when close stream.