support record audio using input device virtual-audio-capturer
正在显示
3 个修改的文件
包含
14 行增加
和
5 行删除
| 1 | webpage_recorder:利用elecron离屏渲染网页,把抓取的页面图像通过pipe传递给ffmpeg,利用ffmpeg编码成视频 | 1 | webpage_recorder:利用elecron离屏渲染网页,把抓取的页面图像通过pipe传递给ffmpeg,利用ffmpeg编码成视频 |
| 2 | -环境要求:npm, electron,ffmpeg | 2 | +环境要求:npm, electron,ffmpeg,virtual-video-capturer(可以从https://sourceforge.net/projects/virtualaudiodev/files/下载) |
| 3 | 3 | ||
| 4 | 安装: | 4 | 安装: |
| 5 | npm install | 5 | npm install |
| 6 | 6 | ||
| 7 | 运行命令示例: | 7 | 运行命令示例: |
| 8 | ;record duration 30s framerate 20fps width 640 height 320 videobitrate 800k | 8 | ;record duration 30s framerate 20fps width 640 height 320 videobitrate 800k |
| 9 | -electron . -u http://182.92.9.182:9090/media/hlsPlayer/hlsPlayer.html -d 30 -f 20 -w 640 -h 320 -b 800k test.mp4 | 9 | +electron . -u http://182.92.9.182:9090/media/hlsPlayer/hlsPlayer.html -d 30 -f 20 -w 640 -h 320 -b 800k test.flv |
| 10 | +ffmpeg -i test.flv -acodec copy -vcodec copy test.mp4 | ||
| 10 | 11 | ||
| 11 | 局限: | 12 | 局限: |
| 12 | 1. electron需要在桌面环境下运行 | 13 | 1. electron需要在桌面环境下运行 |
| 13 | 2. 捕获视频间隔不够均匀 | 14 | 2. 捕获视频间隔不够均匀 |
| 14 | -3. 还不能捕获声音 |
| @@ -109,6 +109,12 @@ function startFFmpeg(videosize) { | @@ -109,6 +109,12 @@ function startFFmpeg(videosize) { | ||
| 109 | args.push('-r'); | 109 | args.push('-r'); |
| 110 | args.push(argv.f); | 110 | args.push(argv.f); |
| 111 | args.push.apply( args, ['-i', 'pipe:0'] ); | 111 | args.push.apply( args, ['-i', 'pipe:0'] ); |
| 112 | + // /* | ||
| 113 | + args.push('-f'); | ||
| 114 | + args.push('dshow'); | ||
| 115 | + args.push('-i'); | ||
| 116 | + args.push('audio=virtual-audio-capturer'); | ||
| 117 | + //*/ | ||
| 112 | args.push('-vf') | 118 | args.push('-vf') |
| 113 | args.push('fps=fps='+argv.f) | 119 | args.push('fps=fps='+argv.f) |
| 114 | args.push('-c:v'); | 120 | args.push('-c:v'); |
| @@ -117,7 +123,9 @@ function startFFmpeg(videosize) { | @@ -117,7 +123,9 @@ function startFFmpeg(videosize) { | ||
| 117 | args.push(argv.b); | 123 | args.push(argv.b); |
| 118 | args.push('-r:v'); | 124 | args.push('-r:v'); |
| 119 | args.push(argv.f); | 125 | args.push(argv.f); |
| 120 | - args.push('-an'); | 126 | + |
| 127 | + args.push('-acodec'); | ||
| 128 | + args.push('aac'); | ||
| 121 | args.push(argv._[0]); | 129 | args.push(argv._[0]); |
| 122 | 130 | ||
| 123 | console.log(args.join` `); | 131 | console.log(args.join` `); |
| 1 | ;record duration 30s framerate 20fps width 640 height 320 videobitrate 800k | 1 | ;record duration 30s framerate 20fps width 640 height 320 videobitrate 800k |
| 2 | -electron . -u http://182.92.9.182:9090/media/hlsPlayer/hlsPlayer.html -d 30 -f 20 -w 640 -h 320 -b 800k test.mp4 | 2 | +electron . -u http://182.92.9.182:9090/media/hlsPlayer/hlsPlayer.html -d 30 -f 20 -w 640 -h 320 -b 800k test.flv |
| 3 | +ffmpeg -i test.flv -vcodec copy -acodec copy test.mp4 |
-
请 注册 或 登录 后发表评论