gpt4 book ai didi

c++ - Gstreamer RTSP 解码帧时间戳

转载 作者:行者123 更新时间:2023-12-05 05:42:28 24 4
gpt4 key购买 nike

我们正在使用 C++ 中的 Gstreamer 解码 RTSP 流帧。我们需要读取帧 NTP 时间戳,我们认为它驻留在 RTCP 数据包中。经过一些文档挖掘,我们发现了一个名为 GstRTPBaseDepayload 的元素。 ,它有一个名为“stats”的属性,它有一个字段“timestamp”,解释为“最后看到的 RTP 时间戳”。

我们原来的管道:

gst-launch-1.0 rtspsrc port-range=5000-5100 location="rtsp://.."latency=300 is-live=true !队列 ! rtph265depay 名称=付款人! video/x-h265 , stream-format=byte-stream, alignment=au ! h265解析! video/x-h265 , stream-format=byte-stream, alignment=au ! appsink name=mysink sync=true

我将 depay 元素命名为 rtph265depay name=dp,然后:

    depayer_=gst_bin_get_by_name(GST_BIN(pipeline_), "dp");
GstStructure * stat;
g_object_get((GstRTPBaseDepayload*)depayer_,"stats",stat);
GType type = gst_structure_get_field_type(stat,"timestamp");

报错说stat结构没有字段,实际上它没有任何字段。我没有找到 GstRTPBaseDepayload 的任何示例用法,并且文档一如既往地缺乏。如果能提供有关帧时间戳的任何指导,我将不胜感激。

编辑:

我还尝试检查 depayer_ 是否具有空值:

depayer_=gst_bin_get_by_name(GST_BIN(pipeline_), "dp");
if(depayer_!=nullptr){
GstStructure * stat;
// GstRTPBaseDepayload* depayload;
g_object_get(depayer_,"stats",stat,NULL);
if(gst_structure_has_field(stat,"timestamp")){ //this line causes segfault
guint timestamp;
gst_structure_get_uint(stat,"timestamp",&timestamp);
}
}

depayer 和 stat 对象都不为空,但是 gst_structure_has_field(stat,"timestamp") 会导致段错误。非常感谢任何帮助。

最佳答案

我想你可以试试

GstStructure *stat;
// GstRTPBaseDepayload* depayload;
g_object_get(depayer_,"stats",&stat,NULL);

注意我在 g_object_get 中使用了 &stat,而不是 stat

https://docs.gtk.org/gobject/method.Object.get.html

我找到了一个例子: https://github.com/pexip/gst-rtsp-server/blob/master/examples/test-mp4.c#L38-L42

关于c++ - Gstreamer RTSP 解码帧时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72014475/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com