gpt4 book ai didi

c - 我应该如何解释 gstreamer multifilesink 时间戳属性?

转载 作者:行者123 更新时间:2023-11-30 14:40:35 28 4
gpt4 key购买 nike

我在 C 中使用 multifilesink 元素。multifilesink 创建带有索引的文件名,但我需要带有时间戳的文件名。方便的是,multifilesink 在写入每个文件后发送总线消息,并且在消息数据中,它提供包含文件名和时间戳的 glib 结构。我已经设置了代码来监视消息并调用函数来重命名每个文件,如下所示:

“file-01.jpg”变为“file-DDMMYYYY_HHMMSS.sss.jpg”

每次写入文件时,我都可以成功接收消息并调用我的函数。

问题是我不明白时间戳的值。它似乎不是 UNIX 纪元时间,它不是单调的,并且该值通常为负数或零。

// My function to handle multifilesink messages
static gboolean HandleElementMessages( GstMessage *MessagePtr )
{
const GstStructure* MessageStructurePtr;
gboolean success = TRUE;

MessageStructurePtr = gst_message_get_structure( MessagePtr );
g_print( "Received an element message from an element of type \"%s\" at time %ld\n",
gst_structure_get_name( MessageStructurePtr ),
GST_MESSAGE_TIMESTAMP( MessageStructurePtr )
);

return success;
} // End of HandleElementMessages()

我希望 GST_MESSAGE_TIMESTAMP() 应该返回一个与纪元或我可以理解的某个起点相关的单调递增值。相反,我看到的结果是这样的:

Received an element message from an element of type "GstMultiFileSink" at time 3282
Received an element message from an element of type "GstMultiFileSink" at time 0
Received an element message from an element of type "GstMultiFileSink" at time 2
Received an element message from an element of type "GstMultiFileSink" at time 0
Received an element message from an element of type "GstMultiFileSink" at time 0
Received an element message from an element of type "GstMultiFileSink" at time 140662536522192
Received an element message from an element of type "GstMultiFileSink" at time -3543839906708188932
...

最佳答案

以下是发送到总线的结构的代码:

  s = gst_structure_new ("GstMultiFileSink",
"filename", G_TYPE_STRING, filename,
"index", G_TYPE_INT, multifilesink->index,
"timestamp", G_TYPE_UINT64, timestamp,
"stream-time", G_TYPE_UINT64, stream_time,
"running-time", G_TYPE_UINT64, running_time,
"duration", G_TYPE_UINT64, duration,
"offset", G_TYPE_UINT64, offset,
"offset-end", G_TYPE_UINT64, offset_end, NULL);

因此,当您获得结构时,您应该使用一些 GstStructure 函数来获取您感兴趣的数据:

guint64 timestamp;

gst_structure_get_uint64(MessageStructurePtr, "timestamp", &timestamp);

关于c - 我应该如何解释 gstreamer multifilesink 时间戳属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55462884/

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