Skip to main content

__debug's Home There is no remedy for love but to love more

坑爹的 gstreamer 推流

有一天突然想把家里的 Raspberry Pi 的摄像头推流到学校的电脑上, 不过直接 P2P 的话需要内网穿透; 虽说家里的路由器可以设置 DMZ 和 DDNS, 但是换个地方就不行了.

考虑利用手头上的 VPS.

方案其实很简单:

		 Relay (VPS)
       tcpserversrc -> tcpserversink
	     /\              \
	    /                 \
	   /                   \
	  /                     \/
   tcpclientsink            tcpclientsrc
Sender (Raspberry Pi)         Receiver

研究这些命令怎么写浪费了大半个晚上…

Sender:

raspivid -n -w 800 -h 600 -b 100000 -fps 24 -t 0 -o - \
| gst-launch-1.0 -v fdsrc \
! h264parse \
! rtph264pay config-interval=10 pt=96 \
! gdppay \
! tcpclientsink host=<RELAY-IP> port=<RELAY-RECV-PORT>

Relay:

gst-launch-1.0 -v tcpserversrc host=localhost port=<RELAY-RECV-PORT> \
! gdpdepay \
! gdppay \
! tcpserversink host=localhost port=<RELAY-SEND-PORT>

Receiver:

gst-launch-1.0 -v tcpclientsrc host=<RELAY-IP> port=<RELAY-SEND-PORT> \
! gdpdepay \
! rtph264depay \
! avdec_h264 \
! videoconvert \
! autovideosink sync=false

Comments

Comments powered by Disqus