一、环境介绍
ffmpge版本: 4.2.2
系统环境: win10 64位
下载地址: https://download.csdn.net/download/xiaolong1126626497/13328939
说明: 采用GDI方式录制屏幕,鼠标光标会闪烁。可以采用DXGI 、WGC采集。
二、命令示例
2.1 列出当前电脑上音频设备、摄像头设备列表
代码语言:javascript复制C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -list_devices true -f dshow -i dummy
输出结果:
代码语言:javascript复制PS D:linux-share-dirvideo_file> C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -list_devices true -f dshow -i dummy
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[dshow @ 02b71840] DirectShow video devices (some may be both video and audio devices)
[dshow @ 02b71840] "Integrated Camera"
[dshow @ 02b71840] Alternative name "@device_pnp_\?usb#vid_5986&pid_2113&mi_00#6&3326332&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}global"
[dshow @ 02b71840] "screen-capture-recorder"
[dshow @ 02b71840] Alternative name "@device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}{4EA6930A-2C8A-4AE6-A561-56E4B5044439}"
[dshow @ 02b71840] DirectShow audio devices
[dshow @ 02b71840] "楹﹀厠椋庨樀鍒?(Conexant SmartAudio HD)"
[dshow @ 02b71840] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}"
[dshow @ 02b71840] "virtual-audio-capturer"
[dshow @ 02b71840] Alternative name "@device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}{8E14549B-DB61-4309-AFA1-3578E927E935}"
2.2 录制桌面全屏图像 音频
代码语言:javascript复制C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f gdigrab -i desktop -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}" -vcodec libx264 -acodec libmp3lame -s 1280x720 -r 15 D:/linux-share-dir/video_file/6666.mp4
其中:
audio= "" 这里填麦克风设备. 第一条指令就是查询电脑上音频设备。把名字复制过来即可。
输出结果:
代码语言:javascript复制PS D:linux-share-dirvideo_file> C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f gdigrab -i desktop -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}" -vcodec libx264 -acodec libmp3lame -s 1280x720 -r 15 D:/linux-share-dir/video_file/6666.mp4
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[gdigrab @ 02e72080] Capturing whole desktop as 1920x1080x32 at (0,0)
[gdigrab @ 02e72080] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, gdigrab, from 'desktop':
Duration: N/A, start: 1628238450.828869, bitrate: 1988680 kb/s
Stream #0:0: Video: bmp, bgra, 1920x1080, 1988680 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, dshow, from 'audio=@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}':
Duration: N/A, start: 149701.343000, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
File 'D:/linux-share-dir/video_file/6666.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (bmp (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 02ee7c80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 02ee7c80] profile High 4:4:4 Predictive, level 3.1, 4:4:4, 8-bit
[libx264 @ 02ee7c80] 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'D:/linux-share-dir/video_file/6666.mp4':
Metadata:
encoder : Lavf58.29.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p(progressive), 1280x720, q=-1--1, 15 fps, 15360 tbn, 15 tbc
Metadata:
encoder : Lavc58.54.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: mp3 (libmp3lame) (mp4a / 0x6134706D), 44100 Hz, stereo, s16p
Metadata:
encoder : Lavc58.54.100 libmp3lame
frame= 98 fps= 24 q=27.0 size= 768kB time=00:00:02.90 bitrate=2169.2kbits/s dup=34 drop=57 speed=0.716x
2.3 录制摄像头 音频
代码语言:javascript复制示例1:
C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f dshow -i video="@device_pnp_\?usb#vid_5986&pid_2113&mi_00#6&3326332&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}global" -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}" -vcodec libx264 -acodec libmp3lame -s 1280x720 -r 15 D:/linux-share-dir/video_file/6666.mp4
其中:
video="" 视频摄像头设备名称
audio="" 视频音频设备名称
示例2:
C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f dshow -i video="@device_pnp_\?usb#vid_5986&pid_2113&mi_00#6&3326332&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}global" -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}" D:/linux-share-dir/video_file/test/202108161456.mp4
2.4 采集桌面指定区域(无音频)
代码语言:javascript复制C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f gdigrab -framerate 6 -offset_x 50 -offset_y 50 -video_size 400x400 -i desktop D:/linux-share-dir/video_file/test/202108161448.mp4
2.5 采集桌面指定区域 音频
代码语言:javascript复制//录制指定范围--采集图像 音频
C:/FFMPEG/ffmpeg_x86_4.2.2/bin/ffmpeg.exe -f gdigrab -framerate 6 -offset_x 50 -offset_y 50 -video_size 400x400 -i desktop -f dshow -i audio="@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}wave_{6E399CBA-5F7D-443F-9071-1657DE0F5483}" D:/linux-share-dir/video_file/test/202108161514.mp4