simplest_ffmpeg_grabdesktop:屏幕录制。 simplest_ffmpeg_readcamera:读取摄像头
最简单的基于FFmpeg的AVDevice例子(屏幕录制) - 雷霄骅(leixiaohua1020)的专栏 - CSDN博客 https://blog.csdn.net/leixiaohua1020/article/details/39706721
D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640×480 -i video=”vide o source name”:audio=”audio source name” -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 1 28k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0-507aab7e9f4ffac0 88a294e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow indev @ 000000000050d3c0] Unable to parse option value "640脳480" as image size [dshow indev @ 000000000050d3c0] Error setting option video_size to value 640脳480. video=鈥漹ideo: Invalid argument D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640×480 -i video="video source name":audio="audio source name" -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0-507aab7e9f4ffac088a2 94e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow indev @ 000000000033d180] Unable to parse option value "640脳480" as image size [dshow indev @ 000000000033d180] Error setting option video_size to value 640脳480. video=video source name:audio=audio source name: Invalid argument D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640*480 -i video="video source name":audio="audio source name" -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k - f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0-507aab7e9f4ffac088a29 4e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow @ 000000000045b880] Could not find video device with name [video source name] among source de vices of type video. video=video source name:audio=audio source name: I/O error D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640*480 -i video="Conexa nt 20561 SmartAudio HD":audio="Conexant 20561 SmartAudio HD" -vcodec libx264 -b 600k -vpre slow -aco dec libfaac -ab 128k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0 -507aab7e9f4ffac088a294e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow @ 00000000004eb940] Could not find video device with name [Conexant 20561 SmartAudio HD] amon g source devices of type video. video=Conexant 20561 SmartAudio HD:audio=Conexant 20561 SmartAudio HD: I/O error D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640*480 -i video="Integr ated Camera":audio="Conexant 20561 SmartAudio HD" -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0-507aab7e9f 4ffac088a294e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow @ 000000000033b8c0] Could not find audio only device with name [Conexant 20561 SmartAudio HD] among source devices of type audio. [dshow @ 000000000033b8c0] Searching for audio device within video devices for Conexant 20561 SmartA udio HD [dshow @ 000000000033b8c0] Could not find audio only device with name [Conexant 20561 SmartAudio HD] among source devices of type video. video=Integrated Camera:audio=Conexant 20561 SmartAudio HD: I/O error D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640*480 -i video="Integr ated Camera":audio="Internal Microphone" -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539737370-0-0-507aab7e9f4ffac088a 294e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow @ 000000000060b880] Could not find audio only device with name [Internal Microphone] among so urce devices of type audio. [dshow @ 000000000060b880] Searching for audio device within video devices for Internal Microphone [dshow @ 000000000060b880] Could not find audio only device with name [Internal Microphone] among so urce devices of type video. video=Integrated Camera:audio=Internal Microphone: I/O error D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin> D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin> D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>ffmpeg -r 25 -f dshow -s 640*480 -i video="Integr ated Camera":audio="Internal Microphone(Conexant 20561 SmartAudio HD)" -vcodec libx264 -b 600k -vpre slow -acodec libfaac -ab 128k -f flv rtmp://streaming.test.com/testAppName/0000?auth_key=1539 737370-0-0-507aab7e9f4ffac088a294e574f63659 ffmpeg version N-92190-gb2adc31697 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 8.2.1 (GCC) 20181011 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls -- enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-li bopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine - -enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-l ibwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --ena ble-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 --enab le-avisynth libavutil 56. 19.101 / 56. 19.101 libavcodec 58. 33.100 / 58. 33.100 libavformat 58. 19.100 / 58. 19.100 libavdevice 58. 4.105 / 58. 4.105 libavfilter 7. 33.101 / 7. 33.101 libswscale 5. 2.100 / 5. 2.100 libswresample 3. 2.100 / 3. 2.100 libpostproc 55. 2.100 / 55. 2.100 [dshow @ 00000000003bc940] Could not RenderStream to connect pins video=Integrated Camera:audio=Internal Microphone(Conexant 20561 SmartAudio HD): I/O error D:\ffmpeg\ffmpeg-20181016-b2adc31-win64-static\bin>
接下来 搭建推流服务器