网站怎么做qq的授权登陆网站设计技术入股
网站怎么做qq的授权登陆,网站设计技术入股,南昌网站关键词推广,广州竞价托管公司前言#xff1a;
FFMPEG的功能强大是毋庸置疑的#xff0c;那么录屏的需求大家在某些时候大家可能是非常需要的#xff0c;例如#xff0c;现有的项目需要演示#xff0c;因此录制一段演示视频#xff1b;亦或者做内容分发直播的#xff0c;比如游戏主播#xff0c;需…前言
FFMPEG的功能强大是毋庸置疑的那么录屏的需求大家在某些时候大家可能是非常需要的例如现有的项目需要演示因此录制一段演示视频亦或者做内容分发直播的比如游戏主播需要录制在玩某个游戏的精彩片段以创建一个后期的视频素材库亦或者通过FFMPEG抓取摄像头的实时画面满足某些人的疯狂的偷窥欲友情提醒大家还是需要做一个守法公民不要看了我的文章然后去做坏事亦或者遇到了某些非常好听或者好看的视频但无法保存此时就需要录屏功能来弥补这些遗憾了亦或者在服务器运维的时候需要做运维审计工作等等录屏需求
而在FFMPEG面前这些功能的实现通常都是一条简简单单的命令就可以完成了
Windows下ffmpeg录屏的主要方式是dshowdirectshow、vfwcap、gdigrab其中dshow可以用来抓取摄像头、采集卡、麦克风等vfwcap主要用来采集摄像头类设备gdigrab则是抓取Windows窗口的程序。
下面将就如何录屏如何确保录屏的质量以及网络推流的一些基本概念做一个简单的介绍
一
电脑录屏和网络推流的概念
电脑录屏指的是在一定的时间内录制电脑上的所有活动比如打开网页播放视频播放音乐等等动作统统都记录最后将这些实时产生的音视频数据流写入指定的文件这些都是本地的活动通常电脑端的录屏活动生成的本地文件是作为视频素材库使用的也就是说后期还需要通过音视频剪辑工具按需裁剪最后按需求分发到网络或者保留在本地自己欣赏
网络推流指的是通过特定软件比如利用摄像头实时捕捉音视频数据流将这些数据主动推送到远程的指定的网络端一般情况下直播实时摄像头这些最终都是网络推流本地是不保存音视频数据的后台本地有时候可能会保存毕竟直播什么的有时候还需要一些审计或者比如交通摄像头事故发生的时候可能需要视频回溯
网络推流和拉流需要一些相应的网络协议支持比如rmtp协议这里就不展开说了
二
基本的录屏
这里说的基本录屏是指的Windows10win7或者win11 无需其它驱动基于Windows操作系统的gdigrab直接录屏但录制的只有视频没有音频
无疑的这样的方式是比较简单的但缺点也是比较大的没有声音只能录制Windows内的整个桌面
命令如下
fmpeg -f gdigrab -i desktop -f mp4 d:/out.mp4 -y
注意这个命令生成的out.mp4文件可能Windows media可能打不开需要使用vlc播放器播放
输出支持的格式也可以是wmaflv 按q退出录屏
一般不需要特别设置比如视频的比特率什么的直接默认就可以了在现在的硬件条件下清晰度基本可以满足录屏主要是CPU运算
注意经过实践在本次实验中mp4格式的视频清晰度最高效果最好
ffmpeg -f gdigrab -i desktop d:/out.flv -y
ffmpeg -f gdigrab -i desktop d:/out.wma -y
这个基本录屏只能录制视频有点不太能满足需求比如翻录某些视频的情况下下面就来一个进阶录屏可以同时录制高清视频和高清音频
三
高清音视频录制
此种方式需要安装虚拟屏幕驱动并启用声卡录音功能主要是基于dshow驱动来进行的
常用的驱动如UScreenCapturescreen-capture-recorder
本例中使用screen-capture-recorder该驱动程序下载地址http://sourceforge.net/projects/screencapturer/files/
###注意该驱动更新频率比较低直接选择最新版本就可以了本例使用的是Setup Screen Capturer Recorder v0.12.11
此程序默认安装就可以了安装完毕后会有一个新的FFMPEG这个FFMPEG版本是比较低的但后面的录屏还只能用这个低版本的FFMPEG高版本的FFMPEG好像用不了 查询dshow驱动执行情况
ffmpeg -list_devices true -f dshow -i dummy
旧新版本的FFMPEG查询现在支持的录屏驱动新的FFMPEG可能是不支持的现在暂时还没有办法第一个命令是旧版FFMPEG第二个命令是新版FFMPEG
C:\Users\AdministratorC:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -list_devices true -f dshow -i dummy
ffmpeg version N-44080-gdfb4757 Copyright (c) 2000-2012 the FFmpeg developersbuilt on Aug 31 2012 16:58:51 with gcc 4.7.1 (GCC)configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zliblibavutil 51. 70.100 / 51. 70.100libavcodec 54. 55.100 / 54. 55.100libavformat 54. 25.104 / 54. 25.104libavdevice 54. 2.100 / 54. 2.100libavfilter 3. 15.101 / 3. 15.101libswscale 2. 1.101 / 2. 1.101libswresample 0. 15.100 / 0. 15.100libpostproc 52. 0.100 / 52. 0.100
[dshow 0292bc80] DirectShow video devices
[dshow 0292bc80] screen-capture-recorder
[dshow 0292bc80] DirectShow audio devices
[dshow 0292bc80] 楹﹀厠椋?(Realtek(R) Audio)
[dshow 0292bc80] virtual-audio-capturer
[dshow 0292bc80] 绔嬩綋澹版贩闊?(Realtek(R) Audio)
dummy: Immediate exit requestedC:\Users\Administratorffmpeg -list_devices true -f dshow -i dummy
ffmpeg version 6.1.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developersbuilt with gcc 12.2.0 (Rev10, Built by MSYS2 project)configuration: --enable-gpl --enable-version3 --enable-static --pkg-configpkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprintlibavutil 58. 29.100 / 58. 29.100libavcodec 60. 31.102 / 60. 31.102libavformat 60. 16.100 / 60. 16.100libavdevice 60. 3.100 / 60. 3.100libavfilter 9. 12.100 / 9. 12.100libswscale 7. 5.100 / 7. 5.100libswresample 4. 12.100 / 4. 12.100libpostproc 57. 3.100 / 57. 3.100
[dshow 000001d0b92ba200] UScreenCapture (video)
[dshow 000001d0b92ba200] Alternative name device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\UScreenCapture
[dshow 000001d0b92ba200] screen-capture-recorder (video)
[dshow 000001d0b92ba200] Alternative name device_sw_{860BB310-5D01-11D0-BD3B-00A0C911CE86}\{4EA69364-2C8A-4AE6-A561-56E4B5044439}
[dshow 000001d0b92ba200] 麦克风 (Realtek(R) Audio) (audio)
[dshow 000001d0b92ba200] Alternative name device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{9A0CE0E2-9E7D-4F81-857D-CF4BA1D888E3}
[dshow 000001d0b92ba200] virtual-audio-capturer (audio)
[dshow 000001d0b92ba200] Alternative name device_sw_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\{8E146464-DB61-4309-AFA1-3578E927E935}
[dshow 000001d0b92ba200] 立体声混音 (Realtek(R) Audio) (audio)
[dshow 000001d0b92ba200] Alternative name device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{E3B2D1FC-6202-4AFE-AC1C-2BD8DD95EB72}
[in#0 000001d0b92ba080] Error opening input: Immediate exit requested
Error opening input file dummy.
Setup Screen Capturer Recorder v0.12.11安装完毕后不需要重启服务器立刻就生效了
这个时候还需要安装Java环境jdk下载地址https://www.java.com/en/download/ 如何安装jdk就不用说了有手就可以安装了没办法jdk是Setup Screen Capturer Recorder v0.12.11的强依赖
还需要打开Windows的录制功能 现在可以开始录制带音频的录屏文件了
C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 d:\out1.flv -y
C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 d:\out1.wma -y
指定输出格式为mp4的时候报错了报错如下
看样子mp4编码转码的时候失败了也就是说该驱动不支持mp4或者和操作系统有关吧
C:\Users\AdministratorC:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 -f mp4 d:\out1.mp4 -y
ffmpeg version N-44080-gdfb4757 Copyright (c) 2000-2012 the FFmpeg developersbuilt on Aug 31 2012 16:58:51 with gcc 4.7.1 (GCC)configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zliblibavutil 51. 70.100 / 51. 70.100libavcodec 54. 55.100 / 54. 55.100libavformat 54. 25.104 / 54. 25.104libavdevice 54. 2.100 / 54. 2.100libavfilter 3. 15.101 / 3. 15.101libswscale 2. 1.101 / 2. 1.101libswresample 0. 15.100 / 0. 15.100libpostproc 52. 0.100 / 52. 0.100
leaving aero on[dshow 029cbe40] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, dshow, from videoscreen-capture-recorder:audiovirtual-audio-capturer:Duration: N/A, start: 30738.314000, bitrate: 1536 kb/sStream #0:0: Video: rawvideo, bgra, 2560x1440, 30 tbr, 10000k tbn, 30 tbcStream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
[libx264 04065b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX AVX2 FMA3 BMI1 BMI2
[libx264 04065b40] profile High, level 5.0
[libx264 04065b40] 264 - core 125 r2208 d9d2288 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac1 ref3 deblock1:0:0 analyse0x3:0x113 mehex subme7 psy1 psy_rd1.00:0.00 mixed_ref1 me_range16 chroma_me1 trellis1 8x8dct1 cqm0 deadzone21,11 fast_pskip1 chroma_qp_offset-2 threads24 lookahead_threads4 sliced_threads0 nr0 decimate1 interlaced0 bluray_compat0 constrained_intra0 bframes3 b_pyramid2 b_adapt1 b_bias0 direct1 weightb1 open_gop0 weightp2 keyint250 keyint_min25 scenecut40 intra_refresh0 rc_lookahead40 rccrf mbtree1 crf23.0 qcomp0.60 qpmin0 qpmax69 qpstep4 ip_ratio1.40 aq1:1.00
Output #0, mp4, to d:\out1.mp4:Metadata:encoder : Lavf54.25.104Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 2560x1440, q-1--1, 10000k tbn, 30 tbcStream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 22050 Hz, stereo, s16, 128 kb/s
Stream mapping:Stream #0:0 - #0:0 (rawvideo - libx264)Stream #0:1 - #0:1 (pcm_s16le - libvo_aacenc)
Press [q] to stop, [?] for help
x264 [error]: malloc of size 15786496 failedime00:00:27.74 bitrate 109.3kbits/s dup3 drop0
Video encoding failed
Received stop event after 2795 passes
换成flv格式的输出文件第二次在执行录屏的时候报错了
[dshow 02a2be40] real-time buffer 100% full! frame dropped!
这个报错说的是buffer溢出了根本原因是输出的文件里有内容了录制的视频不知道如何把数据流写到文件的哪个位置了很简单换一个输出文件名或者把原来的输出文件删除就可以继续录制了 C:\Users\AdministratorC:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 -vol 200 d:\out1.flv -y
ffmpeg version N-44080-gdfb4757 Copyright (c) 2000-2012 the FFmpeg developersbuilt on Aug 31 2012 16:58:51 with gcc 4.7.1 (GCC)configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zliblibavutil 51. 70.100 / 51. 70.100libavcodec 54. 55.100 / 54. 55.100libavformat 54. 25.104 / 54. 25.104libavdevice 54. 2.100 / 54. 2.100libavfilter 3. 15.101 / 3. 15.101libswscale 2. 1.101 / 2. 1.101libswresample 0. 15.100 / 0. 15.100libpostproc 52. 0.100 / 52. 0.100
leaving aero on[dshow 02a2be40] Estimating duration from bitrate, this may be inaccurate
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, dshow, from videoscreen-capture-recorder:audiovirtual-audio-capturer:Duration: N/A, start: 31001.957000, bitrate: 1536 kb/sStream #0:0: Video: rawvideo, bgra, 2560x1440, 30 tbr, 10000k tbn, 30 tbcStream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
File d:\out1.flv already exists. Overwrite ? [y/N] real-time buffer 63% full! frame dropped!
[dshow 02a2be40] real-time buffer 66% full! frame dropped!
[dshow 02a2be40] real-time buffer 68% full! frame dropped!
[dshow 02a2be40] real-time buffer 71% full! frame dropped!
[dshow 02a2be40] real-time buffer 73% full! frame dropped!
[dshow 02a2be40] real-time buffer 76% full! frame dropped!Last message repeated 1 times
[dshow 02a2be40] real-time buffer 78% full! frame dropped!Last message repeated 1 times
[dshow 02a2be40] real-time buffer 80% full! frame dropped!Last message repeated 19 times
[dshow 02a2be40] real-time buffer 83% full! frame dropped!Last message repeated 1 times
[dshow 02a2be40] real-time buffer 85% full! frame dropped!Last message repeated 1 times
[dshow 02a2be40] real-time buffer 88% full! frame dropped!Last message repeated 2 times
[dshow 02a2be40] real-time buffer 90% full! frame dropped!Last message repeated 2 times
[dshow 02a2be40] real-time buffer 93% full! frame dropped!Last message repeated 2 times
[dshow 02a2be40] real-time buffer 95% full! frame dropped!Last message repeated 32 times
[dshow 02a2be40] real-time buffer 98% full! frame dropped!Last message repeated 2 times
[dshow 02a2be40] real-time buffer 100% full! frame dropped!
录制好的视频播放后可以看到确实录制到声音了我的QQ音乐播放的歌曲完全录制进视频内了开心…………^……^
那么到这里就很清楚了如果只需要录制视频那就把audiovirtual-audio-capturer这一段删除反之亦然
上面的录屏参数说明
-f dshow 指定输入的数据流使用dshow驱动-rtbufsize 1202000k 录制时的最大缓存使用量-i videoscreen-capture-recorder:audiovirtual-audio-capturer 从哪抓取数据流这里指定了具体执行动作的驱动-sameq -ar 22050 如果是flv输出的话不使用此参数会报错[flv 0295caa0] flv does not support that sample rate, choose from (44100, 22050, 11025)因此我选择了22050这三个数【44100, 22050, 11025】里面选择一个就可以了 -vol 200 这里是调节声音大小如果电脑内的声音本身比较小放大两倍-s 1940*1440 这里是设置录屏的大小以及-v 15帧率等等等同于-video_size 1280x720注意注意这些录屏属性设置需要放在命令的后面最好是在输出文件之前 例如这样 C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 -vol 200 -s 1920*1440 d:\out1.flv -y -preset ultrafast 视频非常清晰但文件会很大这个效果真的非常nice但我录制了20分钟的游戏视频竟然有7.5G大小 但这样的参数位置将会报错需要特别注意哦
C:\Users\AdministratorC:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -ar 22050 -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -vol 200 -s 1920*1440 d:\out1.flv -y
ffmpeg version N-44080-gdfb4757 Copyright (c) 2000-2012 the FFmpeg developersbuilt on Aug 31 2012 16:58:51 with gcc 4.7.1 (GCC)configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zliblibavutil 51. 70.100 / 51. 70.100libavcodec 54. 55.100 / 54. 55.100libavformat 54. 25.104 / 54. 25.104libavdevice 54. 2.100 / 54. 2.100libavfilter 3. 15.101 / 3. 15.101libswscale 2. 1.101 / 2. 1.101libswresample 0. 15.100 / 0. 15.100libpostproc 52. 0.100 / 52. 0.100
leaving aero on[dshow 0286bf20] Could not set audio options
videoscreen-capture-recorder:audiovirtual-audio-capturer: Input/output error再次强调参数位置问题音视频属性参数一定要在-i 的后面下面是一个完整的例子
C:\Program Files (x86)\Screen Capturer Recorder\configuration_setup_utility\vendor\ffmpeg\bin\ffmpeg.exe -f dshow -rtbufsize 1202000k -i videoscreen-capture-recorder:audiovirtual-audio-capturer -sameq -ar 22050 -vol 200 -preset ultrafast -s 1980*1440 d:\out1.flv -y
顺便说一句音视频剪辑对于硬件也就是cpu和内存的性能要求比较高至少i7 13代32G内存吧
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/86719.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!