Problem with caps between v4l2src and autovideosink

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with caps between v4l2src and autovideosink

Alicia Romero
Hi people!
I have a camera installed in /dev/video0.

The pipeline:
gst-launch -v v4l2src ! autovideosink

works perfectly and I can see which caps between v4l2src and autovideosink are used:
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink: caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)1600, height=(int)1200, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)5/1

Now I want to write a small application doing the same:
  [...]
  source = gst_element_factory_make ("v4l2src", "source");
  sink = gst_element_factory_make ("autovideosink", "sink");
  caps_filter = gst_element_factory_make("capsfilter", "filter");
  [...]
 caps = gst_caps_new_simple("video/x-raw",
              "framerate", GST_TYPE_FRACTION, 5, 1,
              "format", G_TYPE_STRING, "YUY2",
              "width", G_TYPE_INT, 1600,
              "height", G_TYPE_INT, 1200,
              NULL);
 g_object_set(G_OBJECT(caps_filter), "caps", caps, NULL);
  [...]

But it is not working, I get:
Error received from element source: Internal data flow error.
Debugging information: gstbasesrc.c(2933): gst_base_src_loop (): /GstPipeline:test-pipeline/GstV4l2Src:source:
streaming task paused, reason not-negotiated (-4)

I suppose the error is because of the caps incompatibility between v4l2src and caps_filter.
Does anyone know why is not working and which caps can I use in my application?

Thanks!!

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Nicolas Dufresne-3

Le 2014-09-18 06:39, Alicia Romero a écrit :
>               "format", G_TYPE_STRING, "YUY2",
Format isn't a string, it's a GST_TYPE_VIDEO_FORMAT.

>               "width", G_TYPE_INT, 1600,
>               "height", G_TYPE_INT, 1200,
>               NULL);
>  g_object_set(G_OBJECT(caps_filter), "caps", caps, NULL);
>   [...]
>
> But it is not working, I get:
> Error received from element source: Internal data flow error.
> Debugging information: gstbasesrc.c(2933): gst_base_src_loop ():
> /GstPipeline:test-pipeline/GstV4l2Src:source:
> streaming task paused, reason not-negotiated (-4)
>
> I suppose the error is because of the caps incompatibility between
> v4l2src and caps_filter.
> Does anyone know why is not working and which caps can I use in my
> application?
You can trace the negotiation GST_DEBUG="*CAPS*:7", and search for "not
compatible" lines to see what is actually going on. In this case, format
(of type VIDEO_FORMAT) is mandatory, but missing / wrong type. This is
most likely the reason.

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Prabhakar Lad
In reply to this post by Alicia Romero
Hello,

On Thu, Sep 18, 2014 at 11:39 AM, Alicia Romero <[hidden email]> wrote:

> Hi people!
> I have a camera installed in /dev/video0.
>
> The pipeline:
> gst-launch -v v4l2src ! autovideosink
>
> works perfectly and I can see which caps between v4l2src and autovideosink
> are used:
> /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink:
> caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)1600,
> height=(int)1200, interlaced=(boolean)false,
> pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)5/1
>
> Now I want to write a small application doing the same:
>   [...]
>   source = gst_element_factory_make ("v4l2src", "source");
>   sink = gst_element_factory_make ("autovideosink", "sink");
>   caps_filter = gst_element_factory_make("capsfilter", "filter");
>   [...]
>  caps = gst_caps_new_simple("video/x-raw",
>               "framerate", GST_TYPE_FRACTION, 5, 1,
>               "format", G_TYPE_STRING, "YUY2",
>               "width", G_TYPE_INT, 1600,
>               "height", G_TYPE_INT, 1200,
>               NULL);
>  g_object_set(G_OBJECT(caps_filter), "caps", caps, NULL);
>   [...]
>
> But it is not working, I get:
> Error received from element source: Internal data flow error.
> Debugging information: gstbasesrc.c(2933): gst_base_src_loop ():
> /GstPipeline:test-pipeline/GstV4l2Src:source:
> streaming task paused, reason not-negotiated (-4)
>
That wont work if you are trying to add capsfilter, you need to
add videoconvert element after your capsfilter for example try below pipeline,

gst-launch-1.0 -v v4l2src ! video/x-raw, format=YUY2, width=1600,
height=1200,  framerate=5/1 ! videoconvert ! autovideosink

Implement the above pipeline in your program and should be working!

Thanks,
--Prabhakar

> I suppose the error is because of the caps incompatibility between v4l2src
> and caps_filter.
> Does anyone know why is not working and which caps can I use in my
> application?
>
> Thanks!!
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Prabhakar Lad
Hi,

On Thu, Sep 18, 2014 at 5:24 PM, Prabhakar Lad
<[hidden email]> wrote:

> Hello,
>
> On Thu, Sep 18, 2014 at 11:39 AM, Alicia Romero <[hidden email]> wrote:
>> Hi people!
>> I have a camera installed in /dev/video0.
>>
>> The pipeline:
>> gst-launch -v v4l2src ! autovideosink
>>
>> works perfectly and I can see which caps between v4l2src and autovideosink
>> are used:
>> /GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink:
>> caps = video/x-raw-yuv, format=(fourcc)YUY2, width=(int)1600,
>> height=(int)1200, interlaced=(boolean)false,
>> pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)5/1
>>
>> Now I want to write a small application doing the same:
>>   [...]
>>   source = gst_element_factory_make ("v4l2src", "source");
>>   sink = gst_element_factory_make ("autovideosink", "sink");
>>   caps_filter = gst_element_factory_make("capsfilter", "filter");
>>   [...]
>>  caps = gst_caps_new_simple("video/x-raw",
>>               "framerate", GST_TYPE_FRACTION, 5, 1,
>>               "format", G_TYPE_STRING, "YUY2",
>>               "width", G_TYPE_INT, 1600,
>>               "height", G_TYPE_INT, 1200,
>>               NULL);
>>  g_object_set(G_OBJECT(caps_filter), "caps", caps, NULL);
>>   [...]
>>
>> But it is not working, I get:
>> Error received from element source: Internal data flow error.
>> Debugging information: gstbasesrc.c(2933): gst_base_src_loop ():
>> /GstPipeline:test-pipeline/GstV4l2Src:source:
>> streaming task paused, reason not-negotiated (-4)
>>
> That wont work if you are trying to add capsfilter, you need to
> add videoconvert element after your capsfilter for example try below pipeline,
>
> gst-launch-1.0 -v v4l2src ! video/x-raw, format=YUY2, width=1600,
> height=1200,  framerate=5/1 ! videoconvert ! autovideosink
>
> Implement the above pipeline in your program and should be working!
>
Just try the below code:-

Thanks,
--Prabhakar

#include <stdio.h>
#include <unistd.h>

#include <gst/gst.h>
#include <gst/app/gstappsrc.h>

/* to compile gcc sample.c -o sample -Wall `pkg-config --cflags --libs
gstreamer-1.0` */

GstElement *pipeline = NULL;
static GMainLoop *loop;

static gboolean bus_handler (GstBus *bus, GstMessage *msg, gpointer data)
{
    GMainLoop *loop;

    loop = (GMainLoop*)data;

    switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_EOS:
    g_main_loop_quit (loop);
    break;
    case GST_MESSAGE_ERROR:
    {
        gchar *debug;
        GError *error;

        gst_message_parse_error (msg, &error, &debug);
        g_free (debug);

        g_printerr ("Error: %s\n", error->message);
        g_error_free (error);

        g_main_loop_quit (loop);
        break;
    }
    case GST_MESSAGE_STATE_CHANGED:
    {
        GstState state;

        gst_message_parse_state_changed (msg, NULL, &state, NULL);

        break;
    }
    default:
    break;
    }

    return TRUE;
}

int main(int argc, char *argv[])
{
    GstElement *capsfilter, *sink, *v4l2src;
    GstBus *bus;
    guint bus_id;
    GstCaps *caps;

    gst_init (NULL, NULL);

    loop = g_main_loop_new (NULL, FALSE);

    pipeline = gst_pipeline_new ("test_pipeline");
    v4l2src = gst_element_factory_make ("v4l2src", "v4l2src");
    capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
    sink = gst_element_factory_make ("autovideosink", "filesink");

    if (!pipeline || !capsfilter || !sink || !v4l2src) {
        printf ("Could not create all gstreamer elements.\n");
        return 0;
    }

    caps = gst_caps_new_simple("video/x-raw",
        "framerate", GST_TYPE_FRACTION, 5, 1,
        "format", G_TYPE_STRING, "YUY2",
        "width", G_TYPE_INT, 1600,
        "height", G_TYPE_INT, 1200,
        NULL);
    g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);

    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    bus_id = gst_bus_add_watch (bus, bus_handler, loop);
    gst_object_unref (bus);

    gst_bin_add_many (GST_BIN (pipeline), sink, v4l2src, capsfilter, NULL);

    /*gst-launch-1.0 -v v4l2src ! capsfilter caps="video/x-raw,
format=YUY2, width=1600, height=1200,  framerate=5/1" ! autovideosink
*/
    gst_element_link_many (v4l2src, capsfilter, sink, NULL);

    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    g_main_loop_run (loop);

    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (GST_OBJECT (pipeline));
    g_source_remove (bus_id);
    g_main_loop_unref (loop);
    gst_deinit ();

    return 0;
}
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Tim Müller
In reply to this post by Nicolas Dufresne-3
On Thu, 2014-09-18 at 10:09 -0400, Nicolas Dufresne wrote:

> >               "format", G_TYPE_STRING, "YUY2",
> Format isn't a string, it's a GST_TYPE_VIDEO_FORMAT.
> (...) In this case, format
> (of type VIDEO_FORMAT) is mandatory, but missing / wrong type. This is
> most likely the reason.

No, the "format" field in raw audio/video caps is a string.

http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/docs/design/part-mediatype-video-raw.txt#n58

 Cheers
  -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Nicolas Dufresne-3

Le 2014-09-18 13:52, Tim Müller a écrit :
> No, the "format" field in raw audio/video caps is a string.
>
> http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/docs/design/part-mediatype-video-raw.txt#n58
Ah, oops, sorry for the misleading comment then.

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

ebrahim
In reply to this post by Prabhakar Lad
Hi ,  
gcc sample.c -o sample -Wall `pkg-config --cflags --libs gstreamer-1.0`
sample.c:6:31: fatal error: gst/app/gstappsrc.h: No such file or directory
 #include <gst/app/gstappsrc.h>
                               ^
compilation terminated.

when i compile your its throwing error .
could help me in this ?

Reply | Threaded
Open this post in threaded view
|

Re: Problem with caps between v4l2src and autovideosink

Nicolas Dufresne-4
Please reply to email in the proper way. This method does not honer the
linking between messages that allow us to see the thread and the
context. Your message will likely be ignored now as most of us don't
have time to follow a weblink.

best regards,
Nicolas

Le mercredi 05 octobre 2016 à 23:18 -0700, ebrahim a écrit :

> Hi ,  
> gcc sample.c -o sample -Wall `pkg-config --cflags --libs gstreamer-
> 1.0`
> sample.c:6:31: fatal error: gst/app/gstappsrc.h: No such file or
> directory
>  #include <gst/app/gstappsrc.h>
>                                ^
> compilation terminated.
>
> when i compile your its throwing error .
> could help me in this ?
>
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble
> .com/Problem-with-caps-between-v4l2src-and-autovideosink-
> tp4668765p4679956.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel