Example code for muxing klv (meta/x-klv) with mpegtsmux (plugins-bad) and GStreamer 1.8.3

Jean-Sébastien Bilodeau jsbilodeau at cgq.qc.ca
Thu Sep 28 00:21:33 UTC 2017


Hi,

First of all, thank you for your encouraging response and for advice. So it's possible! Is mpegtsmux stable according to your experience?

I actually want to mux KLV metadata for each frame of the video. The example code is my only experience with GStreamer, I have taken code examples here and there and I'm not familiar with their plugin concept and how I can pass my data through a callback (for each frame). Currently, the callback is only called once at the end of the video.

No metadata appear to be muxed in the video file and it's missing a piece of code for now. I modified the need_data function for this:

void need_data(GstElement* element, guint, gpointer userData){
	std::cout << "need_data" << std::endl;

	// TODO push binary data (rtp_KLV_frame_data) in Big-Endian.
	GstBuffer *buffer = gst_buffer_new();
	GstMapInfo map;

	gst_buffer_map(buffer, &map, GST_MAP_WRITE);
	map.data = (guint8*)g_memdup(rtp_KLV_frame_data, rtp_KLV_frame_data_size);
	map.size = rtp_KLV_frame_data_size;
	gst_buffer_unmap (buffer, &map);

	GST_BUFFER_TIMESTAMP(buffer) = appsrc->base_time;
	GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND, 1);
	appsrc->base_time += GST_BUFFER_DURATION (buffer);
	//gst_app_src_push_buffer(GST_APP_SRC(element), buffer);
}

Then I added appsrc to the call of gst_bin_add_many: gst_bin_add_many (GST_BIN (pipeline), src, appsrc, ....

What should I check in relation to the PTS buffer? (The buffer PTS refers to the timestamp when the buffer content should be presented to the user and is not always monotonically increasing.)

Thanks!
________________________________________
De : Arjen Veenhuizen [arjen at moonlightmedia.nl]
Envoyé : mardi 26 septembre 2017 16:12
À : gstreamer-devel at lists.freedesktop.org
Objet : Re: Example code for muxing klv (meta/x-klv) with mpegtsmux (plugins-bad) and GStreamer 1.8.3

It has been a while since I muxed KLV using mpegtsmux, but your approach
seems to be quite about right.
I just had to make sure that I feed the muxer with KLV data *every* (video)
frame and make sure the PTS is correct.

Some python snippets:





Be sure to push an eos event on appsrc srcpad when you are done (e.g.
event-probe the muxer video sync pad for the EOS event), otherwise your
pipeline will stall.

Hope it helps.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/



More information about the gstreamer-devel mailing list