ffmpeg 推送摄像头拍摄内容到服务器

1. 查看机器上所有设备
ffmpeg -devices

ffmpeg version N-93466-g681957b88d Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)

Devices:
 D. = Demuxing supported
 .E = Muxing supported
 --
 D  avfoundation    AVFoundation input device 「摄像头」
 D  lavfi           Libavfilter virtual input device
  E sdl,sdl2        SDL2 output device


2. 查看device信息
ffmpeg -f avfoundation -list_devices true -i ""

[AVFoundation input device @ 0x7f914561f100] AVFoundation video devices:
[AVFoundation input device @ 0x7f914561f100] [0] FaceTime HD Camera
[AVFoundation input device @ 0x7f914561f100] [1] Capture screen 0
[AVFoundation input device @ 0x7f914561f100] AVFoundation audio devices:
[AVFoundation input device @ 0x7f914561f100] [0] Built-in Microphone


3. 测试捕捉摄像头数据保存到文件
ffmpeg -f avfoundation -framerate 30 -i "0" -target pal-vcd [输出文件.mpg]


4. 推送摄像头数据到远程服务器
ffmpeg -f avfoundation -framerate 30 -video_size 320x240 -i  "0"  -vcodec libx264 -acodec libfaac -f flv rtmp://116.196.19.33/test

 

5. 使用vlc播放器即可播放 rtmp://116.196.19.33/test

 

参考命令

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i  "0" -vcodec libx264 -preset ultrafast -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i  "0" -vcodec libx264 -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i  "0"  \-c:v libx264 -preset ultrafast -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i  "0"  -vcodec libx264 -preset ultrafast -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i  "0"  -pixel_format nv12 -preset ultrafast -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i  "0"  -vf format=yuv444p,crop=426:240:507:339 -preset ultrafast -acodec libfaac -f flv  rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -capture_cursor 1 -i 1:0 -r 30000/1001 -s 1280x800 -vsync 2 -c:v libvpx-vp9 -c:a libopus -b:v 1M -b:a 128K capture.webm -f flv rtmp://localhost:1935/zbcs/room

ffmpeg -f avfoundation -pixel_format uyvy422 -i "1" -f flv rtmp://localhost:1935/zbcs/room


//推流桌面 - 只有桌面内容
ffmpeg -f avfoundation -pixel_format uyvy422 -i "1" -f flv rtmp://192.168.10.61:1935/zbcs/room
ffmpeg -f avfoundation -i "1" -vcodec libx264 -preset ultrafast -acodec libfaac -f flv rtmp://192.168.10.61:1935/zbcs/room


//推流摄像头
ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i  "0"  -vcodec libx264 -acodec libfaac -f flv  rtmp://192.168.10.61:1935/zbcs/room


//只推流麦克风
ffmpeg -f avfoundation -i ":0" -vcodec libx264 -preset ultrafast -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://192.168.10.61:1935/zbcs/room


//摄像头+麦克分
ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" -vcodec libx264 -preset ultrafast -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://192.168.10.61:1935/zbcs/room

ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" -vsync 2 -vcodec libx264 -preset ultrafast -acodec libmp3lame -ar 44100 -ac 1 -b:v 1M -b:a 128K -f flv rtmp://192.168.10.61:1935/zbcs/room
 

 

参考:

https://www.jianshu.com/p/575136f63348
https://blog.csdn.net/jeffasd/article/details/71205664?utm_source=blogxgwz0

 

 

修改时间 2019-03-28

真诚赞赏,手留余香
赞赏
随机推荐
Filezilla Server和防火墙设置的相关知识(主动连接和被动连接)
排除选择器
macOS安装composer
20170829临摹手绘
一文看懂npm、yarn、pnpm之间的区别
DedeCMS 如何使用文章列表序号
gyp WARN EACCES user "nobody" does not have permission to access the dev dir
Audio对象的属性
Electron 简介
理解MVC,MVP和MVVM设计模式
QQ号

微信联系我

夜间模式切换
回到顶部