Detecting video stream resolution in appsink with GStreamer 1.0
Fabrizio Dini
dini.fabrizio at gmail.com
Thu Jan 25 17:47:20 UTC 2018
Hello everybody!
I have a little problem in a project of mine that uses a GStreamer pipeline
to get a video stream from an IP camera. The pipeline ends with an appsink,
where a few image processing is made. The problem is that I cannot detect
the video stream resolution because the properties I read does not have
meaningful values.
Please note that the code was written on GStreamer 0.10, and later moved to
GStreamer 1.0, but it was not used for a while, so I cannot say if this
problem is due to changing gst-0.10 with gst-1.0 or not. However...
In the code I start building the pipeline, which is actually just an
uridecodebin plugin. On this plugin "pad-added" signal, I add the app-sink,
query the pad caps and inspect the GstStructure to detect what kind of
video stream I have to handle. The problem is that the fields in the caps
GstStructure seems not have valid values to read.
Properties are read with:
GstStructure* props = gst_caps_get_structure(caps, 0);
and cycled with a for loop on the number of fields (read with
gst_structure_n_fields(props)).
For each property, I read the fieldname:
const gchar* fieldname = gst_structure_nth_field_name(props,j);
and then read the value into a variable, according to the field name. For
example:
if (g_strrstr(fieldname, "width"))
{
res = gst_structure_get_int(props, fieldname, &width);
}
The problem is that gst_structure_get_int() returns false, and
investigating further I've found that the fields I cannot read are not Int
but GstIntRange. However, dumping them with
g_strdup_value_contents(gst_structure_get_value(props, fieldname))
showed that their content is useless. For example, the field "width" had
content "[1,2147483647]" while "framerate" was "[ 0/1, 2147483647/1 ]".
I googled a lot but couldn't find an explanation to this behavior. So,
here's my questions:
What is the correct way to detect video stream properties with GStreamer
1.0? Am I supposed to do that in the callback that receives the buffers?
Can it be done on pad creation?
Thank you very much for your help, and sorry for the long mail...
Fabrizio Dini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180125/4cb7298a/attachment.html>
More information about the gstreamer-devel
mailing list