錄製桌面
-
使用GDI screengrabber可以錄製主屏幕的內容
You can also use gdigrab as input device to grab video from the Windows screen.
To capture all your displays as one big contiguous display:
ffmpeg -f gdigrab -framerate 30 -i desktop output.mkv
If you want to limit to a region, and show the area being grabbed:
ffmpeg -f gdigrab -framerate 30 -offset_x 10 -offset_y 20 -video_size 640x480 -show_region 1 -i desktop output.mkv
To grab the contents of the window named “Calculator”:
ffmpeg -f gdigrab -framerate 30 -i title=Calculator output.mkv
- 存在問題:縮放時耗費時間過長,導致幀率不高
2.使用screen capture recorder無法全屏錄製桌面
錄製音頻
ffmpeg -f dshow -i audio="virtual-audio-capturer" -acodec libmp3lame window.mp3
avdevice_register_all();
pInputFmt = av_find_input_format("dshow");
if (avformat_open_input(&pFmtCtx, "audio=virtual-audio-capturer", pInputFmt, &pOptions) < 0) {
av_log(nullptr, AV_LOG_ERROR, "cant not open input file.\n");
return -1;
}
av_dump_format(pFmtCtx, 0, "audio=virtual-audio-capturer", 0);
錄製攝像頭
查看輸入設備:
ffmpeg.exe -f dshow -list_devices true -i dummy
查看攝像頭圖像:
ffplay.exe -f dshow -video_size 640x480 -i video="HD WebCam"
avdevice_register_all();
pInputFmt = av_find_input_format("dshow");
int ret = avformat_open_input(&m_InputFmtCtx, "video=HD WebCam", pInputFmt, nullptr);
if (ret < 0)
{
av_log(nullptr, AV_LOG_ERROR, "Could not open input file.\n");
goto ERROR_PROC;
}
錄製麥克風
播放麥克風聲音:
ffplay.exe -f dshow -i audio="麥克風 (Realtek High Definition Audio)"
錄製USB攝像頭
ffmpeg.exe -f dshow -video_size 1280x720 -i video="HD USB Camera" -vcodec copy -rtsp_transport tcp -f rtsp rtsp://localhost/test