Skip to main content

__debug's Home Keep it simple, stupid

坑爹的 gstreamer 推流

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

没关系, 我还有一个萌萌哒 VPS. (论 VPS 的作用)

由于某种原因, 要求网络的延迟在 1s 左右, 于是就滚去用 gstreamer 了…

方案其实很简单:

                 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