我该如何解释gstreamer multifilesink timestamp属性?

问题描述 投票:0回答:1

我在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
...
c timestamp gstreamer glib
1个回答
1
投票

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

  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);
© www.soinside.com 2019 - 2024. All rights reserved.