Webm header data
Lee Matthews
lma at spaceapplications.com
Mon Jun 30 11:16:46 PDT 2014
Thanks Sebastian, ok I got it to work by getting streamheader and writing it to the file before filesink starts writing to the file (filesink is set to append in order to avoid writing over the streamheader). The below is my code, in case this could help anyone else.
Lee
--
// Get the caps of the tee element's pad
caps = gst_pad_query_caps (pad,NULL);
// Print the caps
gchar *capsstr;
capsstr = gst_caps_to_string (gst_pad_get_current_caps(pad));
g_print ("caps: %s\n", capsstr);
g_free (capsstr);
// Get the streamheader information
structure = gst_caps_get_structure (caps, 0);
streamheader = gst_structure_get_value (structure, "streamheader");
if(!G_IS_VALUE(streamheader))
{
g_print("No valid value!");
return GST_PAD_PROBE_REMOVE;
}
bufarr = g_value_peek_pointer (streamheader);
// Get the data at the first position within the array
GValue *bufval = &g_array_index (bufarr, GValue, 0);
// Check type of array content
if (G_VALUE_TYPE (bufval) != GST_TYPE_BUFFER)
{
g_print("Not GST_TYPE_BUFFER type!");
return GST_PAD_PROBE_REMOVE;
}
buf = g_value_peek_pointer (bufval); // Get pointer to buffer
// Get a pointer to the streamheader data and get its size
if (gst_buffer_map (buf, &map, GST_MAP_READ))
{
g_print("streamheader memory dump\n");
gst_util_dump_mem (map.data, map.size);
/* Write buffer to disk. */
pFile = fopen("/data/data/com.mobinet.mobinetbootapp/files/test.webm","wb");
if (pFile)
{
fwrite(map.data, map.size, 1, pFile);
g_print("Wrote to file!\n");
}
else
{
g_print("Something wrong writing to File.\n");
}
fclose(pFile);
gst_buffer_unmap (buf, &map);
}
else
g_print("streamheader buffer map FAIL\n");
// Add elements
g_print ("ADDING ELEMENTS!\n");
queue = gst_element_factory_make ("queue", NULL);
filesink = gst_element_factory_make ("filesink", NULL);
g_object_set (filesink, "append", TRUE, NULL);
g_object_set (filesink, "location", "/data/data/com.mobinet.mobinetbootapp/files/test.webm", NULL);
----- Original Message -----
From: "Sebastian Dröge" <sebastian at centricular.com>
To: "Discussion of the development of and with GStreamer" <gstreamer-devel at lists.freedesktop.org>
Sent: Friday, 27 June, 2014 5:01:54 PM
Subject: Re: Webm header data
On Fr, 2014-06-27 at 16:41 +0200, Lee Matthews wrote:
> Thanks Sebastian. Do you have any suggestions as to how I may save my video stream to disk?
>
> I presume I'd have the same problem if I used ogg theora instead of vp8 webm ?
You could get the caps before linking in the filesink, then first send
the streamheaders buffer and then link it into the pipeline.
You'll have the same problem with Ogg, it works exactly the same way
there.
--
Sebastian Dröge, Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list