【问题标题】:How to get current video location name in splitmuxsink?如何在 splitmuxsink 中获取当前视频位置名称?
【发布时间】:2021-03-12 05:09:50
【问题描述】:

我使用splitmuxsink元素根据大小保存视频,我可以使用format-location信号设置下一个用于转储视频的视频名称。

static gchararray
format_location_callback (GstElement * splitmux,
                          guint fragment_id,
                          gpointer udata)
{
  static int i =0;
  gchararray myarray = g_strdup_printf("myvid%d.mp4", i);
  i += 1;

  return myarray;
}

# add a callback signal
g_signal_connect (G_OBJECT (bin->sink), "format-location",
          G_CALLBACK (format_location_callback), bin);

如何获取splitmuxsink 转储的当前视频名称?我认为使用 GstMessages 可能是可行的,但我不确定如何获取与特定插件相关的消息。

实际上,当我使用DEBUG_MODE=4 时,我可以在 splitmuxsink 中看到视频拆分发生时视频名称更改的消息。

0:00:06.238114046 31488 0x55928d253d90 INFO            splitmuxsink gstsplitmuxsink.c:2389:set_next_filename:<sink_sub_bin_sink1> Setting file to myvid0.mp4
0:00:06.238149341 31488 0x55928d253d90 INFO                filesink gstfilesink.c:294:gst_file_sink_set_location:<sink> filename : myvid0.mp4
0:00:06.238160223 31488 0x55928d253d90 INFO                filesink gstfilesink.c:295:gst_file_sink_set_location:<sink> uri   

【问题讨论】:

    标签: c++ c gstreamer gstreamer-1.0


    【解决方案1】:

    通过收听GstBus,我可以使用GST_MESSAGE_ELEMENT 类型的GstMessage 获取视频位置。当视频分割发生时,splitmuxsink 的消息名称为 splitmuxsink-fragment-opened

          const gchar * location;
          const GstStructure* s = gst_message_get_structure(message);
          if (gst_structure_has_name(s, "splitmuxsink-fragment-opened"))
          {
            g_message ("get message: %s",
                  gst_structure_to_string (gst_message_get_structure(message)));
            location = gst_structure_get_string(s, "location");
            cout << location << endl;
          }
    
          break;
        }
    

    输出

    ** Message: 12:00:27.618: get message: splitmuxsink-fragment-opened, location=(string)myvid0.mp4, running-time=(guint64)1199530439;
    myvid0.mp4
    

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 2019-04-06
      • 2016-07-29
      • 1970-01-01
      相关资源
      最近更新 更多