实时视频流

发送sin图像,并接收

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

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

录制屏幕

ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+10,20 output.mp4

Unable to receive RTP payload type 96 without an SDP file describing it

http://bashell.nodemedia.cn/archives/about-sdp-when-streaming-in-rtp-using-ffmpeg.html

ffmpeg -re -i sample1.mp4 -an -c copy -f rtp rtp://127.0.0.1:12345
SDP:
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 57.29.101
m=video 12345 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1

│[rtp @ 0x7fb07c005f20] Protocol not on whitelist ‘file,crypto’!/0
-protocol_whitelist file,udp,rtp

vlc rtsp

vlc -vvv v4l2:///dev/video0:chroma=mjpg:width=1280:height=720 --sout '#transcode{vcodec=mp2v,acodec=none}:rtp{sdp=rtsp://:8554/test.sdp}'
vlc rtsp://127.0.0.1:8554/test.sdp

代码里面decode视频可以用gstreamer
但是rtsp方案延时太大,2~3秒,不知如何加速。

摄像头

https://ffmpeg.org/ffmpeg-devices.html#Device-Options

列出video4linux2(摄像头)支持的各种格式:

ffplay -f video4linux2 -list_formats all /dev/video0

输出结果:

[video4linux2,v4l2 @ 0x7fa8280008c0] Raw       :   yuyv422 :     YUV 4:2:2 (YUYV) : 640x480 320x180 320x240 352x288 424x240 640x360 848x480 960x540 1280x720
[video4linux2,v4l2 @ 0x7fa8280008c0] Compressed:     mjpeg :                MJPEG : 640x480 320x180 320x240 352x288 424x240 640x360 848x480 960x540 1280x720

播放摄像头

ffplay -f video4linux2 -framerate 30 -video_size hd720 /dev/video0
ffplay -f video4linux2 -framerate 30 -video_size 640x480 /dev/video0

录制摄像头到文件

ffmpeg -f video4linux2 -input_format mjpeg -framerate 30 -video_size hd720 -i /dev/video0 out.mp4
ffmpeg -f video4linux2 -input_format mjpeg -framerate 30 -video_size 640x480 -i /dev/video0 out.mp4
ffmpeg -f video4linux2 -input_format yuyv422 -framerate 30 -video_size 640x480 -i /dev/video0 out.mp4

使用ffserver

http://blog.csdn.net/xiaoyangger/article/details/8996328
运行ffserver以提供广播功能
运行ffmpeg往里面写数据
其他人从里面读数据

实时网络摄像头视频流

ffmpeg -f video4linux2 -video_size 1280x720 -i /dev/video0 http://localhost:8090/feed1.ffm

虚拟摄像头设备

https://blog.ptsang.net/virtual_simulate_webcam_in_linux/comment-page-1
http://allonlinux.free.fr/Projets/AVLD/
http://v4l2vd.sourceforge.net/
https://github.com/umlaeute/v4l2loopback/blob/master/examples/test.c

你可能感兴趣的:(服务器搭建)