【流媒体开发】9、ffmpeg实现视频录制
生活随笔
收集整理的這篇文章主要介紹了
【流媒体开发】9、ffmpeg实现视频录制
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用ffmpeg通過錄制音視頻,分為兩種:
1、一種是錄制麥克風和電腦自帶攝像頭的音視頻
2、一種是錄制電腦系統自帶的音頻和錄屏
本節說明一下怎么實現音視頻的錄制,并且進行一些參數的調節
一、安裝、設備查看
1、dshow軟件安裝
- 是桌面錄制和系統音頻錄制的一個插件
- 先安裝dshow軟件 Screen Capturer Recorder,
- 項目地址: https://sourceforge.net/projects/screencapturer/files/
2、查看當前可用于錄制的設備
-
然后查看可用設備名字:ffmpeg -list_devices true -f dshow -i dummy
-
提取關鍵信息如下:
- “Lenovo EasyCamera” #聯想自帶的攝像
- “screen-capture-recorder” #屏幕捕獲器,是dshow軟件虛擬出來的,錄制桌面
- “楹﹀厠椋?(High Definition Audio 璁懼)” #音頻設備麥克風
- “virtual-audio-capturer” #錄制系統聲音,只使用這個錄制出來只有系統的聲音,沒有麥克風的聲音
-
具體打印如下
二、音視頻錄制
1、錄制視頻(默認參數)
- 桌面:
-f dshow:表示插件,-i video表示輸入時桌面錄制設備
- 攝像頭:
2、錄制聲音(默認參數)
- 系統聲音:
- 系統+麥克風聲音:
3、音視頻混合錄制
- 同時錄制聲音和視頻(默認參數)
- 錄制屏幕視頻和系統音頻:
三、錄制參數設置
1、查看可設錄制參數
ffmpeg -f dshow -list_options true -i video=“screen-capture-recorder”
ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developersbuilt with gcc 9.1.1 (GCC) 20190807configuration: --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-libth eora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libv idstab --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-libopenmptlibavutil 56. 31.100 / 56. 31.100libavcodec 58. 54.100 / 58. 54.100libavformat 58. 29.100 / 58. 29.100libavdevice 58. 8.100 / 58. 8.100libavfilter 7. 57.100 / 7. 57.100libswscale 5. 5.100 / 5. 5.100libswresample 3. 5.100 / 3. 5.100libpostproc 55. 5.100 / 55. 5.100 [dshow @ 003df800] DirectShow video device options (from video devices) [dshow @ 003df800] Pin "Capture" (alternative pin name "1") [dshow @ 003df800] pixel_format=bgr0 min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=bgr0 min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=bgr24 min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=rgb555le min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=rgb555le min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=rgb8 min s=1x1 fps=0.02 max s=1920x1080 fps=30 [dshow @ 003df800] pixel_format=yuv420p min s=1x1 fps=0.02 max s=1920x1080 fps=30 leaving aero onvideo=screen-capture-recorder: Immediate exit requested音頻可設參數查看:
ffmpeg -f dshow -list_options true -i audio="virtual-audio-capturer“
2、指定參數錄制
修改錄制的分辨率、幀率、顏色空間、碼率、編碼的格式:
ffmpeg -f dshow -i audio="virtual-audio-capturer" -f dshow -video_size 1920x1080 -framerate 15 -pixel_format yuv420p -i video="screen-capture-recorder" -b:v 3M -vcodec libx264 -y av-out.flv###-framerate 15屬于采集修改為15幀-i video="screen-capture-recorder" -b:v 3M -vcodec libx264 -r 15 -y av-out.flv 這里的-r屬于編碼成15幀總結
以上是生活随笔為你收集整理的【流媒体开发】9、ffmpeg实现视频录制的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dbm数据库详解【flask】【dbm.
- 下一篇: 看看月明光彩照入东 水浒