簡體   English   中英

GStreamer 管道顯示 RTSP stream

[英]GStreamer pipeline to show an RTSP stream

我對 Gstreamer 很陌生。

我需要編寫一個視頻客戶端,能夠使用 GStreamer 從 RTSP 源獲取 stream 數據。 我將 VLC 配置為 stream 我在筆記本電腦上使用 RTSP 的視頻,我想創建一個管道來獲取 stream 並顯示它。 我嘗試使用playbin ,一切正常。 關鍵是我需要微調用於 stream 視頻的延遲,但似乎我不能用 playbin 做到這一點。

我嘗試rtspsrc因為它允許處理延遲但我不知道如何在任何 window 上顯示視頻。這就是我創建的管道:

gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/test latency=300 ! decodebin ! autovideosink

我收到錯誤“流式傳輸任務暫停,原因未協商 (-4)”。

在深入查看 inte.net 后,我嘗試了不同的管道,但我肯定錯過了一些東西。 如何編寫 gstreamer 管道來顯示來自 RTSP 的視頻?

最終目標是有一個至少在延遲方面可以調整的管道,所以我有兩個選擇:

  • 如果可能,設置 playbin 元素的延遲。 (此元素正確顯示視頻)
  • 使用正確的管道顯示視頻,因為 rtspsrc 允許我設置延遲。

我使用 Xubuntu 16.04、gstreamer-tools-1.0(也使用 0.10)和帶有 VLC 的視頻 I stream 具有 mp4 擴展名。

您可以通過設置正確的屬性並使用 playbin 組件來調整延遲:

gst-launch-1.0 -v playbin uri=rtsp://localhost:8554/test uridecodebin0::source::latency=300

希望你覺得這個有用 :)

假設 rtsp 流是 h264 格式,使用顯式 h264 解碼器和編碼器來解析流。 使用 videoconvert 和 videoscale 更改幀形狀。

gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/test latency=100 ! queue ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! autovideosink

我上次檢查時playbin確實有一個latency選項。 請注意,它的比例與rtspsrc rtspsrc以毫秒為單位,而playbin以納秒為單位。 它可能仍然不會低於某個閾值 - 取決於輸入視頻要求(vbv 緩沖區限制)。

對於您的rtspsrc管道,您可能會在autovideosink之前錯過videoconvertautovideosonvert元素。

我一直在努力完成這項工作,並在樹莓派 3 上取得了成功,所以我想“好吧,因為這很容易,所以我會在 rpi4 上嘗試”按照相同的步驟安裝 gstream,但是在運行命令時:

gst-launch-1.0 rtspsrc location=rtsp://localhost:8554/test latency=100,隊列,rtph264depay! h264解析! avdec_h264 ! 視頻轉換! 視頻比例! 視頻/x-raw,寬度=640,高度=480! 自動視頻接收器

它看起來像一個熱像儀。 盡管如此,仍然可以在 rpi3 上正常工作。 不確定這里會有什么不同。

在我的例子中,我收到了一個視頻 stream,從 android 智能手機(服務器)到 nvidia jetson nano(客戶端)的延遲令人印象深刻,以便稍后進行推理處理,並且以下字符串有效:

pipeline = "rtspsrc location=rtsp://admin:admin@192.xxx.x.xx:xxxx latency=0, queue, rtph264depay !h264parse !avdec_h264 !videoconvert !videoscale !video/x-raw,width=640,height =480 !appsink"

在管道中用“avdec_h264”替換“omxh264dec”解碼器后,它們消失了以下棄用:

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_caps_is_empty: 斷言 'GST_IS_CAPS (caps)' 失敗

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_caps_truncate: 斷言 'GST_IS_CAPS (caps)' 失敗

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_caps_fixate: 斷言 'GST_IS_CAPS (caps)' 失敗

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_caps_get_structure: 斷言 'GST_IS_CAPS (caps)' 失敗

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_structure_get_string: assertion 'structure != NULL' 失敗

(python3:10659): GStreamer-CRITICAL **: 22:47:22.966: gst_mini_object_unref: assertion 'mini_object != NULL' 失敗

我希望我有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM