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

来源:互联网 发布:java this super 区别 编辑:程序博客网 时间:2024/06/03 21:29

话不多说命令如下:

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 0
原创粉丝点击