FFmpeg 命令:从入门到精通 | ffmpeg 命令视频录制
- FFmpeg 命令:从入门到精通 | ffmpeg 命令视频录制
- 安装软件:Screen Capturer Recorder
- 查看可用设备名字
- 音视频录制
- 录制视频(默认参数)
- 录制声音(默认参数)
- 同时录制系统 + 麦克风声音和视频(默认参数)
- 查看视频录制的可选参数
- 查看音频录制的可选参数
- 指定参数录制音视频
FFmpeg 命令:从入门到精通 | ffmpeg 命令视频录制
本节主要介绍了ffmpeg 命令进行音视频录制的方法,并列举了一些例子。
安装软件:Screen Capturer Recorder
项目地址:on screen capture recorder to video free Files
安装最新版本:
安装软件:
查看可用设备名字
完成安装后,我们可以在命令行输入以下命令查看电脑的可用设备名字:
ffmpeg -list_devices true -f dshow -i dummy
输出以下结果:
[dshow @ 000001e3fded3800] "Integrated Camera" (video)
[dshow @ 000001e3fded3800] Alternative name "@device_pnp_\\?\usb#vid_13d3&pid_56a6&mi_00#6&1c1093a4&1&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000001e3fded3800] "screen-capture-recorder" (video)
[dshow @ 000001e3fded3800] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA69364-2C8A-4AE6-A561-56E4B5044439}"
[dshow @ 000001e3fded3800] "OBS Virtual Camera" (video)
[dshow @ 000001e3fded3800] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{A3FCE0F5-3493-419F-958A-ABA1250EC20B}"
[dshow @ 000001e3fded3800] "麦克风 (Realtek(R) Audio)" (audio)
[dshow @ 000001e3fded3800] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{E35D34C8-3763-4470-BDFF-5999B6DB4347}"
[dshow @ 000001e3fded3800] "virtual-audio-capturer" (audio)
[dshow @ 000001e3fded3800] Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E146464-DB61-4309-AFA1-3578E927E935}"
[dshow @ 000001e3fded3800] "立体声混音 (Realtek(R) Audio)" (audio)
[dshow @ 000001e3fded3800] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{159589C7-204D-4C6C-8804-B576E8B7DC6C}"
dummy: Immediate exit requested
其中:
- “Integrated Camera”:笔记本摄像头
- “screen-capture-recorder”:录制桌面的设备
- “麦克风 (Realtek® Audio)”:麦克风
- “virtual-audio-capturer”:录制系统声音的设备
音视频录制
录制视频(默认参数)
桌面:
ffmpeg -f dshow -i video="screen-capture-recorder" v-out.mp4
摄像头:
ffmpeg -f dshow -i video="Integrated Camera" -y v-out2.flv
注:要根据自己摄像头名称。
录制声音(默认参数)
系统声音:
ffmpeg -f dshow -i audio="virtual-audio-capturer" a-out.aac
注:Ctrl + C 退出录制。
系统 + 麦克风声音:
ffmpeg -f dshow -i audio="麦克风 (Realtek(R) Audio)" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 a-out2.aac
注:要根据自己麦克风名称。
同时录制系统 + 麦克风声音和视频(默认参数)
ffmpeg -f dshow -i audio="麦克风 (Realtek(R) Audio)" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video="screen-capture-recorder" -y av-out.flv
查看视频录制的可选参数
查看 screen-capture-recorder 相关参数:
ffmpeg -f dshow -list_options true -i video="screen-capture-recorder"
输出:
[dshow @ 0000023f4f3a3740] DirectShow video device options (from video devices)
[dshow @ 0000023f4f3a3740] Pin "Capture" (alternative pin name "1")
[dshow @ 0000023f4f3a3740] pixel_format=bgr0 min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=bgr0 min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=bgr24 min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=rgb555le min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=rgb555le min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=rgb8 min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] pixel_format=yuv420p min s=1x1 fps=0.02 max s=1920x1080 fps=30
[dshow @ 0000023f4f3a3740] Could not find output pin from video capture device.
video=screen-capture-recorder: I/O error
查看音频录制的可选参数
查看 virtual-audio-capturer 相关参数:
ffmpeg -f dshow -list_options true -i audio="virtual-audio-capturer"
输出:
[dshow @ 0000024b7e113740] DirectShow audio only device options (from audio devices)
[dshow @ 0000024b7e113740] Pin "Capture Virtual Audio Pin" (alternative pin name "1")
[dshow @ 0000024b7e113740] ch= 2, bits=16, rate= 48000
audio=virtual-audio-capturer: Immediate exit requested
查看 麦克风 (Realtek(R) Audio) 相关参数:
ffmpeg -f dshow -list_options true -i audio="麦克风 (Realtek(R) Audio)"
输出:
[dshow @ 00000260768b3700] DirectShow audio only device options (from audio devices)
[dshow @ 00000260768b3700] Pin "Capture" (alternative pin name "Capture")
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 44100Last message repeated 1 times
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 44100
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 32000
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 32000
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 22050
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 22050
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 11025
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 11025
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 8000
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 8000
[dshow @ 00000260768b3700] ch= 2, bits= 8, rate= 44100
[dshow @ 00000260768b3700] ch= 1, bits= 8, rate= 44100
[dshow @ 00000260768b3700] ch= 2, bits= 8, rate= 22050
[dshow @ 00000260768b3700] ch= 1, bits= 8, rate= 22050
[dshow @ 00000260768b3700] ch= 2, bits= 8, rate= 11025
[dshow @ 00000260768b3700] ch= 1, bits= 8, rate= 11025
[dshow @ 00000260768b3700] ch= 2, bits= 8, rate= 8000
[dshow @ 00000260768b3700] ch= 1, bits= 8, rate= 8000
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 48000
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 48000
[dshow @ 00000260768b3700] ch= 2, bits=16, rate= 96000
[dshow @ 00000260768b3700] ch= 1, bits=16, rate= 96000
audio=麦克风 (Realtek(R) Audio): Immediate exit requested
指定参数录制音视频
ffmpeg -f dshow -i audio="麦克风 (Realtek(R) Audio)" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -video_size 1920x1080 -framerate 15 -pixel_format yuv420p -i video="screen-capture-recorder" -vcodec h264_qsv -b:v 3M -y av-out.flv
ffmpeg -f dshow -i audio="麦克风 (Realtek(R) Audio)" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video="screen-capture-recorder" -vcodec h264_qsv -b:v 3M -r 15 -y av-out2.mp4
ffmpeg -f dshow -i audio="麦克风 (Realtek(R) Audio)" -f dshow -i audio="virtual-audio-capturer" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -framerate 15 -pixel_format yuv420p -i video="screen-capture-recorder" -vcodec h264_qsv -b:v 3M -r 15 -y av-out3.mp4
参数:
- -video_size:视频大小
- -vcodec:视频编码格式
- -framerate:视频帧率
- -pixel_format:视频像素格式
- -b:v:视频码率
- -r:帧率