5 Star 3 Fork 1

Ligo / capture-image

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index_old.js 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
worship 提交于 2018-04-12 18:28 . ffmpeg command tools, tow pipes.
// jshint esversion: 6, globalstrict: true, strict: true
'use strict';
var fs = require('fs');
var P2J = require('pipe2jpeg');
var spawn = require('child_process').spawn;
var jpegCounter = 0;
var params = [
/* log info to console */
'-loglevel',
'quiet',
/* use an artificial video input */
'-f',
'avfoundation',
'-video_size',
//'1024x768',
'3264x2448',
'-framerate',
'20',
//'15',
'-video_device_index',
'2',
'-i',
'Doccamera',
/* set output flags */
'-an',
'-c:v',
'mjpeg',
'-pix_fmt',
'yuvj422p',
'-f',
'image2pipe',//image2pipe, singlejpeg, mjpeg, or mpjpeg
'-q',
'2',
'-t',
'5',
'-r',
'20',
'pipe:1'
];
var p2j = new P2J();
p2j.on('jpeg', (jpeg) => {
console.log('received jpeg', ++jpegCounter);
var fpath = 'c' + jpegCounter + '.jpeg';
fs.writeFile(fpath, jpeg, function(err){
if (err) {
return console.log(err);
}
console.log('saved.');
})
});
const ffmpeg = spawn('ffmpeg', params, {stdio : ['ignore', 'pipe', 'ignore']});
ffmpeg.on('error', (error) => {
console.log(error);
});
ffmpeg.on('exit', (code, signal) => {
console.log('exit', code, signal);
});
ffmpeg.stdout.pipe(p2j);
const convert_preivew = spawn('ffmpeg', params, {stdio : ['ignore', 'pipe', 'ignore']});
1
https://gitee.com/ligord/capture-image.git
git@gitee.com:ligord/capture-image.git
ligord
capture-image
capture-image
master

搜索帮助