【发布时间】:2019-04-01 20:14:21
【问题描述】:
我在 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
...
【问题讨论】:
-
GST_MESSAGE_TIMESTAMP() 需要一个 GstMessage* 参数,您似乎提供了一个 GstStructure* ?
-
感谢您指出这一点。当我解决这个问题时,它总是返回 -1。
标签: c timestamp gstreamer glib