利用ffmpeg进行摄像头提取视频编码为h264通过RTP发送数据到指定的rtp地址

话不多说命令如下:

ffmpeg -f dshow -i video="Logitech QuickCam Easy/Cool" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f rtp rtp://127.0.0.1:6666>sd.sdp

用此命令可以产生264的rtp流, video="Logitech QuickCam Easy/Cool" 为摄像头的名字,-vcodec libx264表示采用264编码器,-preset:v ultrafast -tune:v zerolatency表示实时编码,>sd.sdp表示产生sdp,此sdp的作用是提供给接收rtp流的信息,接收rtp流的一方读取这个文件就可以接受流显示。

但是因为此命令产生的h264流是用yuv444编码的,所以接收方要想存储h264流的话,得在发送方的命令加一个参数:

-pixfmt YUV420P

至于有人问怎么知道摄像头的名字,用这个命令就好了:

ffmpeg -list_devices true -f dshow -i dummy

基本这样就大功告成了~


from: http://www.aichengxu.com/other/1438151.htm







Streaming a simple RTP audio stream from FFmpeg ¶

FFmpeg can stream a single stream using the RTP protocol. In order to avoid buffering problems on the other hand, the streaming should be done through the -re option, which means that the stream will be streamed in real-time (i.e. it slows it down to simulate a live streaming source.

For example the following command will generate a signal, and will stream it to the port 1234 on localhost:

ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://127.0.0.1:1234

To play the stream with ffplay (which has some caveats, see above), run the command:

ffplay rtp://127.0.0.1:1234

Note that rtp by default uses UDP, which, for large streams, can cause packet loss. See the "point to point" section in this document for hints if this ever happens to you.


from:https://trac.ffmpeg.org/wiki/StreamingGuide

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值