No Video

Ian Davidson id012c3076 at blueyonder.co.uk
Mon Jan 7 01:17:54 PST 2013


Hi Kris,

You are correct when you say that you did not explain why my program 
didn't work - but I tried your advice and now have 2 programs which 
don't work.

I use a gst_parse_launch, passing it a string such as

    "v4l2src norm=PAL ! videorate !
    'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1'
    ! queue ! mux. alsasrc ! audioconvert !
    'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux !
    filesink location=file.avi"

but when I run the program I get a message
GStreamer-CRITICAL **: gst_element_make_from_uri: assertion 
`gst_uri_is_valid (uri)' failed

I spent a good while chasing wild geese, asuming that the problem must 
be with the file name I passed in for the filesink - but then studied 
the debug trace more closely to see this extract

    (SBCRecord2:2968): GStreamer-CRITICAL **: gst_element_make_from_uri:
    assertion `gst_uri_is_valid (uri)' failed
    0:00:00.172690420 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:827:priv_gst_parse_yyparse:[00m no source element for
    URI "/x-raw,rate=44100,channels=2'"
    0:00:00.172703486 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:744:priv_gst_parse_yyparse:[00m link without source element
    0:00:00.172715265 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:750:priv_gst_parse_yyparse:[00m link without sink element

    (SBCRecord2:2968): GStreamer-CRITICAL **: gst_element_make_from_uri:
    assertion `gst_uri_is_valid (uri)' failed
    0:00:00.172740072 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:827:priv_gst_parse_yyparse:[00m no source element for
    URI
    "/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1'"
    0:00:00.172753256 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:744:priv_gst_parse_yyparse:[00m link without source element
    0:00:00.172764467 [335m 2968[00m       0xc5f830 [31;01mERROR  [00m
    [00;01;37;41m        GST_PIPELINE
    ./grammar.y:750:priv_gst_parse_yyparse:[00m link without sink element


For some reason, the caps I am passing in of " 
'audio/x-raw,rate=44100,channels=2'" has been pulled apart and then 
found to be broken.  So copy-and-paste from a good command line into the 
C program did not have 100% success.

Any help to get one (or both) versions of my program working would be 
appreciated.

Ian


On 05/01/2013 22:36, Krzysztof Konopko wrote:
> Hi Ian,
>
> I don't know what particular problem in your app is, but in a situation
> when a pipeline works with gst-launch-1.0, but a C app doesn't, my stock
> advise is: copy your command line pipeline and use [1].
>
> You can start writing something dead simple and than introduce whatever
> complexity you need ensuring it still works at each step. In your
> particular case IMO you've introduced too much complexity.
>
> BTW, by using [1] your error checking reduces to something like this
> (pilfered/inspired from/by gst-launch.c):
>
> if (!pipeline) {
>    g_printerr ("ERROR: pipeline could not be constructed: %s\n",
>      error ? GST_STR_NULL (error->message) : "(unknown error)");
>    goto untergang;
> } else if (error) {
>    g_printerr ("Erroneous pipeline: %s\n", GST_STR_NULL (error->message));
>    goto untergang;
> }
>
> [1]
> http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstParse.html#gst-parse-launch
>
> Kris
>
> On 05/01/13 17:06, Ian Davidson wrote:
>> If I use the following command, I can record Audio and Video into an AVI
>> File.
>>
>> gst-launch-1.0 -e v4l2src norm=PAL ! videorate !
>> 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1'
>> ! queue ! mux. alsasrc ! audioconvert !
>> 'audio/x-raw,rate=44100,channels=2' ! queue ! mux. avimux name=mux !
>> filesink location=script-test.avi
>>
>> I would like to replicate that in a program and my program is below.
>> However, the video does not make it through - the Audio plays OK when I
>> play the avi file.
>>
>> It had been suggested that videorate and audiorate might be beneficial
>> for me.  In my program, if I included audiorate (as indicated by the
>> commented out lines), I just heard a brief burst of sound at the
>> beginning of the clip, whereas without audiorate, I heard the full
>> audio.  Including/excluding videorate does not seem to make any
>> difference at the moment.
>>
>> I tried to set a value for "norm" on the v4l2src as PAL, but the
>> compiler did not recognise the ENUM value.  The only way I could set it
>> was to use the value indicated by gst-inspect.
>>
>> I assume that I have done something stupid again, but I cannot see what
>> it is.
>>
>> Thanks for your help.
>>
>> Ian
>>
>> #include <gst/gst.h>
>> #include <glib.h>
>>
>>
>> static gboolean
>> bus_call (GstBus     *bus,
>>            GstMessage *msg,
>>            gpointer    data)
>> {
>>    GMainLoop *loop = (GMainLoop *) data;
>>
>>    switch (GST_MESSAGE_TYPE (msg)) {
>>
>>      case GST_MESSAGE_EOS:
>>        g_print ("End of stream\n");
>>        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;
>>      }
>>      default:
>>        break;
>>    }
>>
>>    return TRUE;
>> }
>>
>>
>> static void
>> on_pad_added (GstElement *element,
>>                GstPad     *pad,
>>                gpointer    data)
>> {
>>    GstPad *sinkpad;
>>    GstElement *decoder = (GstElement *) data;
>>
>>    /* We can now link this pad with the vorbis-decoder sink pad */
>>    g_print ("Dynamic pad created, linking demuxer/decoder\n");
>>
>>    sinkpad = gst_element_get_static_pad (decoder, "sink");
>>
>>    gst_pad_link (pad, sinkpad);
>>
>>    gst_object_unref (sinkpad);
>> }
>>
>>
>>
>> int
>> main (int   argc,
>>        char *argv[])
>> {
>>    GMainLoop *loop;
>>
>>    GstElement *pipeline, *vsource, *vcapsfilter, *vidrate, *queue1;
>>    GstElement *asource, *aconv, *audrate, *acapsfilter, *queue2;
>>    GstElement *mux, *sink;
>>    GstBus *bus;
>>    guint bus_watch_id;
>>
>>    GstCaps *caps;
>>
>>    /* Initialisation */
>>    gst_init (&argc, &argv);
>>
>>    loop = g_main_loop_new (NULL, FALSE);
>>
>>
>>    /* Check input arguments */
>>    if (argc != 2) {
>>      g_printerr ("Usage: %s <AVI filename>\n", argv[0]);
>>      return -1;
>>    }
>>
>>
>>    /* Create gstreamer elements */
>>    pipeline     = gst_pipeline_new ("av-recorder");
>>    vsource      = gst_element_factory_make ("v4l2src",     "vid-source");
>>    vcapsfilter  = gst_element_factory_make ("capsfilter",  "vid-caps");
>>    vidrate      = gst_element_factory_make ("videorate",   "vidrate");
>>    queue1       = gst_element_factory_make ("queue",       "queue1");
>>    asource      = gst_element_factory_make ("alsasrc",     "alsa-source");
>>    aconv        = gst_element_factory_make ("audioconvert", "audio-conv");
>>    acapsfilter  = gst_element_factory_make ("capsfilter",  "audio-caps");
>>    audrate      = gst_element_factory_make ("audiorate",   "audrate");
>>    queue2       = gst_element_factory_make ("queue",       "queue2");
>>    mux          = gst_element_factory_make ("avimux",      "avi-mux");
>>    sink         = gst_element_factory_make ("filesink",    "file-output");
>>
>>    if (!pipeline || !vsource || !vcapsfilter || !vidrate || !queue1 ||
>> !asource || !aconv || !audrate || !acapsfilter || !queue2 || !mux ||
>> !sink) {
>>      g_printerr ("One element could not be created. Exiting.\n");
>>      return -1;
>>    }
>>
>>    /* Set up the pipeline */
>>
>>    /* we set the output filename to the sink element */
>>    g_object_set (G_OBJECT (sink), "location", argv[1], NULL);
>>
>>    /* we set the video capabilities on the vidcaps element */
>>    caps =
>> gst_caps_from_string("video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)25/1");
>>    g_object_set (G_OBJECT (vcapsfilter), "caps", caps, NULL);
>>    gst_caps_unref (caps);
>>
>>    /* we set the audio capabilities on the audiocaps element */
>>    caps = gst_caps_from_string("audio/x-raw,rate=44100,channels=2");
>>    g_object_set (G_OBJECT (acapsfilter), "caps", caps, NULL);
>>    gst_caps_unref (caps);
>>
>>    g_object_set (G_OBJECT (vsource), "norm", 255, NULL);
>>
>>    /* we add a message handler */
>>    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>>    bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
>>    gst_object_unref (bus);
>>
>>    /* we add all elements into the pipeline */
>>    /*      vsource, vcapsfilter, vidrate, queue1,
>>            asource, aconv, acapsfilter, queue2,
>>            mux, sink */
>>    gst_bin_add_many (GST_BIN (pipeline),
>>                          vsource,  vcapsfilter, queue1,
>> /*                        vsource, vidrate, vcapsfilter, queue1,*/
>>                          asource, aconv,  acapsfilter, queue2,
>> /*                        asource, aconv, audrate, acapsfilter, queue2,*/
>>                          mux, sink, NULL);
>>
>>    /* we link the elements together */
>>    /*      vsource -> vcapsfilter -> vidrate -> queue1 -> avimux
>>            asource -> aconv -> acapsfilter -> queue2 -> avimux
>>            mux -> sink */
>>    gst_element_link_many (vsource, vcapsfilter,  queue1, mux, NULL);
>> /*  gst_element_link_many (vsource, vcapsfilter, vidrate, queue1, mux,
>> NULL);*/
>>    gst_element_link_many (asource, aconv,  acapsfilter, queue2, mux, NULL);
>> /*  gst_element_link_many (asource, aconv, audrate, acapsfilter, queue2,
>> mux, NULL);*/
>>    gst_element_link_many (mux, sink, NULL);
>>
>>
>>    /* Set the pipeline to "playing" state*/
>>    g_print ("Now recording: %s\n", argv[1]);
>>    gst_element_set_state (pipeline, GST_STATE_PLAYING);
>>
>>
>>    /* Iterate */
>>    g_print ("Recording (or not!)...\n");
>>    g_main_loop_run (loop);
>>
>>
>>    /* Out of the main loop, clean up nicely */
>>    g_print ("Returned, stopping recording\n");
>>    gst_element_set_state (pipeline, GST_STATE_NULL);
>>
>>    g_print ("Deleting pipeline\n");
>>    gst_object_unref (GST_OBJECT (pipeline));
>>    g_source_remove (bus_watch_id);
>>    g_main_loop_unref (loop);
>>
>>    return 0;
>> }
>> -- 
>> --
>> Ian Davidson
>> --
>>

-- 
--
Ian Davidson
--
Facts used in this message may or may not reflect an underlying 
objective reality. Facts are supplied for personal use only.
Recipients quoting supplied information do so at their own risk. Facts 
supplied may vary in whole or part from widely accepted standards.
While painstakingly researched, facts may or may not be indicative of 
actually occurring events or natural phenomena.
The author accepts no responsibility for personal loss or injury 
resulting from memorisation and subsequent use.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130107/35f6a234/attachment-0001.html>


More information about the gstreamer-devel mailing list