linking filters with caps
Krzysztof Konopko
krzysztof.konopko at youview.com
Thu Nov 1 15:46:35 PDT 2012
Hi Chuck,
I guess you're using x264enc.
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
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:[00m trying to link element
> VideoSrc:(any) to element capsfilter0:sink
> Nov 1 17:08:39 0:00:00.064704777 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;37;41m GST_ELEMENT_PADS
> gstelement.c:944:gst_element_get_static_pad:[00m found pad capsfilter0:sink
> Nov 1 17:08:39 0:00:00.064792569 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstutils.c:1493:prepare_link_maybe_ghosting:[00m VideoSrc and capsfilter0
> in same bin, no need for ghost pads
> Nov 1 17:08:39 0:00:00.064950133 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstpad.c:1886:gst_pad_link_prepare:[00m trying to link VideoSrc:src and
> capsfilter0:sink
> Nov 1 17:08:39 0:00:00.069477022 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstpad.c:2059:gst_pad_link:[00m linked VideoSrc:src and capsfilter0:sink,
> successful
> Nov 1 17:08:39 0:00:00.069674954 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;37;41m GST_ELEMENT_PADS
> gstutils.c:1585:gst_element_link_pads:[00m trying to link element
> capsfilter0:src to element VideoEncoder:(any)
> Nov 1 17:08:39 0:00:00.069755204 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;37;41m GST_ELEMENT_PADS
> gstelement.c:944:gst_element_get_static_pad:[00m found pad capsfilter0:src
> Nov 1 17:08:39 0:00:00.069826303 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstutils.c:1046:gst_pad_check_link:[00m trying to link capsfilter0:src and
> VideoEncoder:src
> Nov 1 17:08:39 0:00:00.069883154 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstutils.c:1066:gst_pad_check_link:[00m Sink pad VideoEncoder:src is not
> sink pad, failed
> Nov 1 17:08:39 0:00:00.069939587 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;31;41m GST_PADS
> gstutils.c:1046:gst_pad_check_link:[00m trying to link capsfilter0:src and
> VideoEncoder:sink
> Nov 1 17:08:39 0:00:00.084800392 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;01;37;41m GST_ELEMENT_PADS
> gstutils.c:1209:gst_element_get_compatible_pad:<VideoEncoder>[00m Could
> not find a compatible pad to link to capsfilter0:src
> Nov 1 17:08:39 0:00:00.084907739 [335m22354[00m 0x88462d8
> [32;01mINFO [00m [00;04m default
> gstutils.c:1873:gst_element_link_pads_filtered:[00m 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
>
More information about the gstreamer-devel
mailing list