linking filters with caps

Tim-Philipp Müller t.i.m at zen.co.uk
Thu Nov 1 15:52:56 PDT 2012


On Thu, 2012-11-01 at 22:46 +0000, Krzysztof Konopko wrote:

Hi,

> For the "format" capability you should use GST_TYPE_FOURCC rather than
> G_TYPE_STRING even though the documentation says it's string (that's why
> it's still ugly I guess :)
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-ugly-plugins/html/gst-plugins-ugly-plugins-x264enc.html

Not really. This is a 0.10 vs. 1.0 thing. In 0.10 the caps would

   video/x-raw-yuv,format=(fourcc)...

in 1.0 it's

   video/x-raw-yuv,format=(string)...

(not necessarily the same identifiers)

Cheers
 -Tim

> If you try to run your app with GST_DEBUG=GST_CAPS:4 you should see
> something like this (among others):
> 
> 0:00:00.076610990  2450  0x9751aa0 DEBUG               GST_CAPS
> gstutils.c:913:gst_element_get_compatible_pad_template: intersecting
> video/x-raw-yuv, format=(string)I420, width=(int)720, height=(int)480,
> framerate=(fraction)30/1
> 0:00:00.076628924  2450  0x9751aa0 DEBUG               GST_CAPS
> gstutils.c:915:gst_element_get_compatible_pad_template: ..and
> video/x-raw-yuv, format=(fourcc){ I420, YV12 }, framerate=(fraction)[
> 0/1, 2147483647/1 ], width=(int)[ 16, 2147483647 ], height=(int)[ 16,
> 2147483647 ]
> 0:00:00.076652937  2450  0x9751aa0 DEBUG               GST_CAPS
> gstutils.c:921:gst_element_get_compatible_pad_template: caps are not
> compatible
> 
> The catch here is the "fourcc" type not matching requested "string" type
> while everything else seem to match when intersecting caps.
> 
> Even better approach is to try gst-launch in such situation. The
> following helped me to prove my theory (no errors when using fourcc type):
> 
> gst-launch videotestsrc ! 'video/x-raw-yuv, format=(fourcc)I420,
> width=(int)720, height=(int)480, framerate=(fraction)30/1' ! x264enc
> tune=4 byte-stream=true bitrate=1024 ! fakesink
> 
> Kris
> 
> On 01/11/12 21:23, Chuck Crisler wrote:
> > Please help! I am stumped and confused by the terminology. I am using
> > GStreamer 0.10.(not sure). I am trying to capture from V4l2 and feed into
> > an H264 encoder (hardly novel). I want to specify the capture size and
> > format (I420). So I setup a caps filter. Here is a snipit of my code.
> > 
> >       g_object_set (G_OBJECT (source_), "device",
> > inputOptions_.ParameterDetails.adapter.cDevice,
> >                     "always-copy", FALSE, NULL);
> >       GstCaps *pSrcCaps = gst_caps_new_simple("video/x-raw-yuv",
> >           "format", G_TYPE_STRING, "I420", "width", G_TYPE_INT, 720,
> > "height", G_TYPE_INT, 480,
> >           "framerate", GST_TYPE_FRACTION, 30, 1, NULL);
> > 
> >       // Initialize the encoder.
> >       g_object_set (G_OBJECT (encoder_), "tune", (guint)4,  // zerolatency
> >                     "byte-stream", (gboolean)TRUE,
> >                     "bitrate",
> > (guint)inputOptions_.ParameterDetails.adapter.iTransmitBitrate, NULL);
> > ...
> > 
> >       // Add the elements to the pipeline.
> >       gst_bin_add_many(GST_BIN(mainPipeline_), source_, encoder_, muxer_,
> > sink_, NULL);
> >       // Link the pipeline together.
> >       bRet = gst_element_link_filtered(source_, encoder_, pSrcCaps);
> >       gst_caps_unref(pSrcCaps);
> >       if (!bRet)
> >       {
> >          GST_DEBUG("Failed to link filtered elements in pipeline.");
> >          return bRet;
> >       }
> > 
> > It is complaining that it can't link the video source to the encoder with
> > my caps filter.
> > 
> > Here is a snipit of the log.
> > 
> > gstutils.c:1585:gst_element_link_pads: trying to link element
> > VideoSrc:(any) to element capsfilter0:sink
> > Nov  1 17:08:39 0:00:00.064704777 22354  0x88462d8
> > INFO        GST_ELEMENT_PADS
> > gstelement.c:944:gst_element_get_static_pad: found pad capsfilter0:sink
> > Nov  1 17:08:39 0:00:00.064792569 22354  0x88462d8
> > INFO                GST_PADS
> > gstutils.c:1493:prepare_link_maybe_ghosting: VideoSrc and capsfilter0
> > in same bin, no need for ghost pads
> > Nov  1 17:08:39 0:00:00.064950133 22354  0x88462d8
> > INFO                GST_PADS
> > gstpad.c:1886:gst_pad_link_prepare: trying to link VideoSrc:src and
> > capsfilter0:sink
> > Nov  1 17:08:39 0:00:00.069477022 22354  0x88462d8
> > INFO                GST_PADS
> > gstpad.c:2059:gst_pad_link: linked VideoSrc:src and capsfilter0:sink,
> > successful
> > Nov  1 17:08:39 0:00:00.069674954 22354  0x88462d8
> > INFO        GST_ELEMENT_PADS
> > gstutils.c:1585:gst_element_link_pads: trying to link element
> > capsfilter0:src to element VideoEncoder:(any)
> > Nov  1 17:08:39 0:00:00.069755204 22354  0x88462d8
> > INFO        GST_ELEMENT_PADS
> > gstelement.c:944:gst_element_get_static_pad: found pad capsfilter0:src
> > Nov  1 17:08:39 0:00:00.069826303 22354  0x88462d8
> > INFO                GST_PADS
> > gstutils.c:1046:gst_pad_check_link: trying to link capsfilter0:src and
> > VideoEncoder:src
> > Nov  1 17:08:39 0:00:00.069883154 22354  0x88462d8
> > INFO                GST_PADS
> > gstutils.c:1066:gst_pad_check_link: Sink pad VideoEncoder:src is not
> > sink pad, failed
> > Nov  1 17:08:39 0:00:00.069939587 22354  0x88462d8
> > INFO                GST_PADS
> > gstutils.c:1046:gst_pad_check_link: trying to link capsfilter0:src and
> > VideoEncoder:sink
> > Nov  1 17:08:39 0:00:00.084800392 22354  0x88462d8
> > INFO        GST_ELEMENT_PADS
> > gstutils.c:1209:gst_element_get_compatible_pad:<VideoEncoder> Could
> > not find a compatible pad to link to capsfilter0:src
> > Nov  1 17:08:39 0:00:00.084907739 22354  0x88462d8
> > INFO                 default
> > gstutils.c:1873:gst_element_link_pads_filtered: Could not link elements
> > 
> > 
> > Can anyone see my (probably silly/simple) mistake and point me in the right
> > direction?
> > 
> > Thank you very much!
> > 
> > 
> > 
> > _______________________________________________
> > gstreamer-devel mailing list
> > gstreamer-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> > 
> 
> _______________________________________________
> 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