ffmpeg在Linux下用X11grab进行屏幕录像,在Windows下用DirectShow滤镜
首先需要安装一个软件,screen capture recorder
编译好的下载地址是:
http://sourceforge.net/projects/screencapturer/
源码地址是:
https://github.com/rdp/screen-capture-recorder-to-video-windows-free
安装完了之后,在命令行执行:
- ffmpeg -list_devices true -f dshow -i dummy
系统输出大致如下:
- [dshow @ 002db420] DirectShow video devices
- [dshow @ 002db420] "screen-capture-recorder"
- [dshow @ 002db420] DirectShow audio devices
- [dshow @ 002db420] "virtual-audio-capturer"
ffmpeg已经可以捕获到DirectShow视频设备,和音频设备了.
"screen-capture-recorder" 这个就是桌面捕获设备,如果电脑上连有摄像头,也会列出来.
"virtual-audio-capturer" 这个是音频捕获设备
然后就可以用FFMPEG来进行录像了
- ffmpeg -f dshow -i video="screen-capture-recorder" -f dshow -i audio="virtual-audio-capturer" -pix_fmt yuv420p -vcodec libx264 -acodec libvo_aacenc -s 1280x720 -r 25 -q 10 -ar 44100 -ac 2 -tune zerolatency -preset ultrafast -f mpegts - | ffmpeg -f mpegts -i - -c copy -bsf:a aac_adtstoasc -f flv temp.flv