我嘗試使用相機模塊將Raspberry Pi 3中的H264 RTP流製作爲視頻標籤。H264與gstreamer-1.0的RTP流
使用下面的代碼來啓動流
raspivid -t 0 -h 720 -w 1080 -fps 25 -hf -b 2000000 -o - | \
gst-launch-1.0 -v fdsrc \
! h264parse \
! rtph264pay \
! gdppay \
! udpsink host="192.168.0.11" port=5000
然後我提供了一個簡單的網頁與視頻標籤:
<video id="videoTag" src="h264.sdp" autoplay>
<p class="warning">Your browser does not support the video tag.</p>
</video>
在src引用以下SDP文件:
v=0
m=video 5000 RTP/AVP 96
c=IN IP4 192.168.0.51
a=rtpmap:96 H264/90000
當我加載網頁沒有任何反應,並且js控制檯完全是空的。
於是,我就查看與VLC流,並得到了以下錯誤:
[00007efd80c03ea8] es demux error: cannot peek
[00007efd80c03ea8] es demux error: cannot peek
[00007efd80c03ea8] live555 demux error: no data received in 10s, aborting
我認爲沒有當年UDP通信可言,所以我從遠程計算機進行了測試:
gst-launch-1.0 udpsrc port=5000 \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" \
! fakesink dump=true
ans收到UDP數據包。所以,我研究着,發現這個:
https://cardinalpeak.com/blog/the-many-ways-to-stream-video-using-rtp-and-rtsp/
現在很顯然,我需要2個端口一個數據流,並建立RTP控制協議。然而,我不知道如何用gstreamer做到這一點。
最糟糕的是,當我運行:
gst-inspect-1.0 | grep -i rtcp
我什麼也沒得到。
如何用gstreamer-1.0將視頻流啓動到使用RTP協議的網頁內的視頻標籤?
更新
使用videotestsrc作爲gstreamer的videosoruce和除去gdppay(它引起無效RTP有效載荷的錯誤),我能夠從遠程客戶端與VLC查看視頻流和與此gstreamer的代碼:
gst-launch-1.0 udpsrc port=5000 \
caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" \
! rtph264depay \
! avdec_h264 \
! autovideosink
你爲什麼認爲瀏覽器將播放RTP流? HTML5視頻的支持格式範圍有限,H.264 over RTP不是其中之一。 –