如何在splitmuxsink中获得当前视频位置名称?



我使用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   

通过收听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

最新更新