查看计算机视频设备
C:\ffmpeg\bin>ffmpeg -list_devices true -f dshow -i dummy
ffmpeg version N-86755-g0780ad9 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.1.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
libavutil 55. 67.100 / 55. 67.100
libavcodec 57.100.104 / 57.100.104
libavformat 57. 75.100 / 57. 75.100
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 95.100 / 6. 95.100
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100
[dshow @ 00000000006e6ba0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 00000000006e6ba0] "USB Camera"
[dshow @ 00000000006e6ba0] Alternative name "@device_pnp_\\?\usb#vid_0c45&pid_62f1&mi_00#7&2565be12&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 00000000006e6ba0] DirectShow audio devices
[dshow @ 00000000006e6ba0] "楹﹀厠椋?(USB Microphone)"
[dshow @ 00000000006e6ba0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{4090F641-BFE6-41C4-B4D8-5BCBCB4CE42B}"
[dshow @ 00000000006e6ba0] "楹﹀厠椋?(Realtek High Definition Audio)"
[dshow @ 00000000006e6ba0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{23464E51-3451-4509-B60D-7401A768EC5D}"
dummy: Immediate exit requested
播放当前摄像机视频
ffplay -f dshow -i video="USB Camera"
ffmpeg -f dshow -i video="USB2.0 PC CAMERA" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1935/live/123
ffmpeg -f dshow -i video="USB Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1935/live1
ffmpeg -f dshow -i video="USB Camera" -vcodec libx264 -f flv -s 120x80 -framerate 15 -rtbufsize 702000k rtmp://127.0.0.1:1935/live1
ffmpeg -copytb 1 -rtsp_transport tcp -i rtsp://admin:admin.123@192.168.50.234 -vcodec libx264 -acodec aac -copyts -f flv -s 480x320 rtmp://pili-publish.xaxiaoba.cn/2017deaohw/dw004
ffmpeg.exe -y -rtbufsize 100M -f dshow -framerate 45 -i video="USB Camera" -c:v libx264 -r 45 -preset ultrafast -tune zerolatency -crf 28 -pix_fmt yuv420p -b:a 128k rtmp://127.0.0.1:1935/live1
ffplay -f dshow -i video="USB Camera"
ffmpeg.exe -f dshow -i video="USB Camera" -vcodec libx264 rtmp://127.0.0.1:1935/live/123
ffmpeg摄像头推流
ffmpeg -f dshow -i video="Integrated Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f mpegts udp://230.0.0.1:6000
默认是640x480 我I5的机器用了10%的CPU
-r 25 设置帧率
-s 1280x720 指定分辨率 默认640x480
-g 1 -keyint_min 2 设置关键帧间隔 默认的间隔太大 加载时间会很长
-b 1000k 设置码率 这个是设置1000kbps的 效果还是蛮好的 如果只设置视频的码率 -b:v 1000k
下面的这个是出Hls流的例子
1
ffmpeg -f dshow -i video="Integrated Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f hls d:/mp4/test.m3u8
-hls_time 2.0 表示每个切片的长度是2秒
-hls_list_size 5表示m3u8的里面切片列表是5个文件
ffmpeg -f dshow -i video="USB Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f mpegts udp://172.162.0.101:6000\