<div dir="ltr"><div></div><div>I don't see exactly what you are doing wrong. You are in fact setting the "width" on a caps structure and not the GstAppSrc (which is correct). It looks like something is trying to set the "width" on the GstAppSrc but it is unclear what is trying to do that. You might be able to narrow it down by stepping through the GstAppSrc with a debugger ... or perhaps that error is unrelated to the real problem.<br></div><div><br></div><div>It looks like the "omx" plugin is searching for a config file or a key file that it cannot load. I don't have any experience with that plugin but I guess you would need to fix that part. You might try a different encoder (like x264) to get around that omx problem.</div><div><br></div><div>Sometimes it helps to add a queue in the pipeline (perhaps before your encoder) ... I don't know enough to say whether that would help here but it might be worth a shot.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 12, 2018 at 5:43 AM Mario García <<a href="mailto:garciam4d@gmail.com">garciam4d@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all.<div><br><div>My application consist of pushing images from a folder (actually now is not reading the info, but is emulate this bytes values with black to almost white) to a gstremaer pipeline (appsrc --> videoconvert --> capsfilter --> omxh264enc -->h264parse --> rtph264pay -->udpsink ) using the appsrc plugin. </div><div><br></div><div>In addition, I would like that the program runs until I want to. Hence there is a loop which calls "push" function infinite times. </div><div><br></div><div>THE CODE: </div><div><div>#include <gst/gst.h></div><div>#include <stddef.h></div><div>#include <stdlib.h></div><div>#include <string.h></div><div>#include <stdio.h></div><div>#include <gst/app/gstappsrc.h></div><div>#include <gst/app/gstappsink.h></div><div>#include <malloc.h></div><div>#define TOP 10</div><div>#define HEIGHTF 512</div><div>#define WIDTHF 640</div><div><br></div><div><br></div><div>int main(int argc, char *argv[])</div><div>{</div><div><span style="white-space:pre-wrap"> </span></div><div> <span style="white-space:pre-wrap"> </span>GstElement *pipeline, *source, *convert, *enc, *parse, *rtppay, *sink, *capsFilter;</div><div> GstCaps *capsSource, *capsConvert;</div><div><span style="white-space:pre-wrap"> </span>GstBus *bus;</div><div><span style="white-space:pre-wrap"> </span>GstMessage *msg;</div><div><span style="white-space:pre-wrap"> </span>GstStateChangeReturn ret;</div><div><span style="white-space:pre-wrap"> </span>GstFlowReturn Ret;</div><div><span style="white-space:pre-wrap"> </span> </div><div><span style="white-space:pre-wrap"> </span>/* Initialize GStreamer */</div><div><span style="white-space:pre-wrap"> </span>gst_init (&argc, &argv);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>/* Create the elements */</div><div><span style="white-space:pre-wrap"> </span>//1-SOURCE</div><div><span style="white-space:pre-wrap"> </span>source = gst_element_factory_make ("appsrc", NULL);</div><div><span style="white-space:pre-wrap"> </span>//Source caps</div><div> capsSource = gst_caps_new_simple ("video/x-raw",</div><div> "format", G_TYPE_STRING, "GRAY8",</div><div> "width", G_TYPE_INT, 640,</div><div> "height", G_TYPE_INT, 512, </div><div><span style="white-space:pre-wrap"> </span> "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,</div><div><span style="white-space:pre-wrap"> </span> "interlace-mode", G_TYPE_STRING, "progressive", NULL) ;</div><div> gst_app_src_set_caps (GST_APP_SRC(source), capsSource);</div><div><span style="white-space:pre-wrap"> </span>//Set the block propierty to TRUE</div><div><span style="white-space:pre-wrap"> </span>g_object_set(source, "block", TRUE, NULL);</div><div><span style="white-space:pre-wrap"> </span>//Set the max-bytes propierty<span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>g_object_set(source, "max-bytes", 655360, NULL);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>//2-CONVERSION </div><div><span style="white-space:pre-wrap"> </span>convert = gst_element_factory_make ("videoconvert", NULL);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>//3-CAPS Filter</div><div><span style="white-space:pre-wrap"> </span>capsFilter = gst_element_factory_make ("capsfilter", NULL);</div><div><span style="white-space:pre-wrap"> </span>capsConvert = gst_caps_new_simple ("video/x-raw",</div><div> "format", G_TYPE_STRING, "I420", NULL);</div><div><span style="white-space:pre-wrap"> </span>g_object_set(capsFilter, "caps", capsConvert, NULL);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>//4-CODEC </div><div><span style="white-space:pre-wrap"> </span>enc = gst_element_factory_make ("omxh264enc", "enc");</div><div><span style="white-space:pre-wrap"> </span>g_object_set(enc, "bitrate", 1000000, NULL);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>//5-PARSSING</div><div><span style="white-space:pre-wrap"> </span>parse = gst_element_factory_make ("h264parse", "parse"); </div><div><br></div><div> <span style="white-space:pre-wrap"> </span>//6-RTP PAYLOAD</div><div><span style="white-space:pre-wrap"> </span>rtppay = gst_element_factory_make ("rtph264pay", "rtppay");</div><div><span style="white-space:pre-wrap"> </span>g_object_set (G_OBJECT (rtppay), "ssrc", 575096457, NULL);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>//7-DESTINATION</div><div><span style="white-space:pre-wrap"> </span>sink = gst_element_factory_make ("udpsink", "sink");</div><div><span style="white-space:pre-wrap"> </span>g_object_set(G_OBJECT (sink), "host", "127.0.0.1", NULL );</div><div><span style="white-space:pre-wrap"> </span>g_object_set(G_OBJECT (sink), "port", 9078, NULL );</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>/* Create the empty pipeline */</div><div> <span style="white-space:pre-wrap"> </span>pipeline = gst_pipeline_new ("test-pipeline");</div><div><span style="white-space:pre-wrap"> </span> </div><div><span style="white-space:pre-wrap"> </span>if (!pipeline || !source || !convert || !capsFilter || !enc || !parse || !rtppay || !sink) {</div><div><span style="white-space:pre-wrap"> </span> g_printerr ("Not all elements could be created.\n"); </div><div><span style="white-space:pre-wrap"> </span> return -1;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>/* Build the pipeline */</div><div><span style="white-space:pre-wrap"> </span>gst_bin_add_many (GST_BIN (pipeline), source, convert, capsFilter, enc, parse, rtppay, sink, NULL);</div><div><span style="white-space:pre-wrap"> </span>if (gst_element_link_many (source, convert, capsFilter, enc, parse, rtppay, sink, NULL) != TRUE) { </div><div><span style="white-space:pre-wrap"> </span> g_printerr ("Elements could not be linked.\n");</div><div><span style="white-space:pre-wrap"> </span> gst_object_unref (pipeline);</div><div><span style="white-space:pre-wrap"> </span> return -1;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>/* Start playing */</div><div><span style="white-space:pre-wrap"> </span>ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);</div><div><span style="white-space:pre-wrap"> </span>if (ret == GST_STATE_CHANGE_FAILURE) {</div><div><span style="white-space:pre-wrap"> </span> g_printerr ("Unable to set the pipeline to the playing state.\n");</div><div><span style="white-space:pre-wrap"> </span> gst_object_unref (pipeline);</div><div><span style="white-space:pre-wrap"> </span> return -1;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span></div><div><br></div><div><span style="white-space:pre-wrap"> </span>//CREATE AND FEED BUFFER</div><div><span style="white-space:pre-wrap"> </span>GstBuffer *buf;</div><div><span style="white-space:pre-wrap"> </span>GstMapInfo map;<span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>int imageCount=0;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>while (imageCount<TOP){</div><div><span style="white-space:pre-wrap"> </span>//Allocate and create Buffer</div><div><span style="white-space:pre-wrap"> </span>buf=gst_buffer_new_and_alloc(HEIGHTF*WIDTHF);</div><div><span style="white-space:pre-wrap"> </span>//To avoid coping in memory</div><div><span style="white-space:pre-wrap"> </span>gst_buffer_map(buf, &map, GST_MAP_WRITE);</div><div><span style="white-space:pre-wrap"> </span>// We set the buffer to values from 0 (black) to 234 (almost white)</div><div><span style="white-space:pre-wrap"> </span>memset (map.data, 26*imageCount, HEIGHTF*WIDTHF);</div><div><span style="white-space:pre-wrap"> </span>//Unmap</div><div><span style="white-space:pre-wrap"> </span>gst_buffer_unmap(buf, &map);</div><div><span style="white-space:pre-wrap"> </span>//Push</div><div><span style="white-space:pre-wrap"> </span>Ret=gst_app_src_push_buffer(GST_APP_SRC(source), buf);</div><div><span style="white-space:pre-wrap"> </span>if (Ret!=GST_FLOW_OK) </div><div><span style="white-space:pre-wrap"> </span>printf ("\nError pushing buffer");</div><div><span style="white-space:pre-wrap"> </span>//keep the loop alive<span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>imageCount++;</div><div><span style="white-space:pre-wrap"> </span>if(imageCount==10)</div><div><span style="white-space:pre-wrap"> </span>imageCount=0;</div><div><span style="white-space:pre-wrap"> </span>}<span style="white-space:pre-wrap"> </span></div><div><br></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>/* Wait until error or EOS */</div><div><span style="white-space:pre-wrap"> </span>bus = gst_element_get_bus (pipeline);</div><div><span style="white-space:pre-wrap"> </span>msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>/* Parse message */</div><div><span style="white-space:pre-wrap"> </span>if (msg != NULL) {</div><div><span style="white-space:pre-wrap"> </span>GError *err;</div><div><span style="white-space:pre-wrap"> </span>gchar *debug_info;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>switch (GST_MESSAGE_TYPE (msg)) {</div><div><span style="white-space:pre-wrap"> </span>case GST_MESSAGE_ERROR:</div><div><span style="white-space:pre-wrap"> </span>gst_message_parse_error (msg, &err, &debug_info);</div><div><span style="white-space:pre-wrap"> </span>g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);</div><div><span style="white-space:pre-wrap"> </span>g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");</div><div><span style="white-space:pre-wrap"> </span>g_clear_error (&err);</div><div><span style="white-space:pre-wrap"> </span>g_free (debug_info);</div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span> case GST_MESSAGE_EOS:</div><div><span style="white-space:pre-wrap"> </span>g_print ("End-Of-Stream reached.\n");</div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span> default:</div><div><span style="white-space:pre-wrap"> </span>/* We should not reach here because we only asked for ERRORs and EOS */</div><div><span style="white-space:pre-wrap"> </span>g_printerr ("Unexpected message received.\n");</div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>gst_message_unref (msg);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>/* Free resources */</div><div><span style="white-space:pre-wrap"> </span>gst_object_unref (bus);</div><div><span style="white-space:pre-wrap"> </span>gst_element_set_state (pipeline, GST_STATE_NULL);</div><div><span style="white-space:pre-wrap"> </span>gst_object_unref (pipeline);/* Create the empty pipeline */</div><div><span style="white-space:pre-wrap"> </span>pipeline = gst_pipeline_new ("test-pipeline");</div><div><br></div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>return 0;</div><div>}</div></div><div><br></div><div>It compile without errors, but when I execute I obtain the next output. I do not know how to continue, because it seem like the speed of feeding is wrong or maybe an allocation memory issue. Please, if someone could help me, I would be very grateful. </div><div><br></div><div>DEBUG INFO </div><div>ubuntu@tegra-ubuntu:~/mario/Project/MarioApp/Images_app$ ./ALLIMAGESMEMGST </div><div>0:00:00.060633916 4114 0x139d20 DEBUG appsrc gstappsrc.c:1147:gst_app_src_set_caps:<appsrc0> setting caps to video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.060954416 4114 0x139d20 DEBUG appsrc gstappsrc.c:1300:gst_app_src_set_max_bytes:<appsrc0> setting max-bytes to 655360</div><div><br></div><div>(ALLIMAGESMEMGST:4114): GLib-GObject-WARNING **: g_object_set_valist: object class 'GstAppSrc' has no property named 'width'</div><div>0:00:00.070510333 4114 0x139d20 WARN omx /dvs/git/dirty/git-master_linux/external/gstreamer/gst-omx/omx/gstomx.c:2814:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /home/ubuntu/.config:/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)</div><div>0:00:00.091209833 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.093006166 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.095336833 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096090833 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096366500 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>0:00:00.096731416 4114 0x139d20 DEBUG appsrc gstappsrc.c:591:gst_app_src_internal_get_caps:<appsrc0> caps: video/x-raw, format=(string)GRAY8, width=(int)640, height=(int)512, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive</div><div>Inside NvxLiteH264DecoderLowLatencyInitNvxLiteH264DecoderLowLatencyInit set DPB and Mjstreaming0:00:00.123102833 4114 0x139d20 DEBUG appsrc gstappsrc.c:742:gst_app_src_start:<appsrc0> starting</div><div>0:00:00.123251750 4114 0x139d20 DEBUG appsrc gstappsrc.c:1222:gst_app_src_get_size:<appsrc0> getting size of -1</div><div>0:00:00.123316083 4114 0x139d20 DEBUG appsrc gstappsrc.c:865:gst_app_src_do_seek:<appsrc0> seeking to 0, format bytes</div><div>0:00:00.123684083 4114 0x14bbb0 FIXME default gstutils.c:3648:gst_pad_create_stream_id_printf_valist:<appsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id</div><div>0:00:00.124006083 4114 0x139d20 DEBUG appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x181160</div><div>0:00:00.124418750 4114 0x139d20 DEBUG appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x181200</div><div>0:00:00.124764333 4114 0x139d20 DEBUG appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.124814416 4114 0x139d20 DEBUG appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.124853666 4114 0x139d20 DEBUG appsrc gstappsrc.c:1523:gst_app_src_push_buffer_full:<appsrc0> waiting for free space</div><div>0:00:00.125336916 4114 0x14bbb0 WARN GST_PADS gstpad.c:3669:gst_pad_peer_query:<appsrc0:src> could not send sticky events</div><div>0:00:00.125457583 4114 0x14bbb0 DEBUG appsrc gstappsrc.c:1052:gst_app_src_create:<appsrc0> we have buffer 0x181160 of size 327680</div><div>0:00:00.126733083 4114 0x14bbb0 WARN basesrc gstbasesrc.c:2865:gst_base_src_loop:<appsrc0> error: Internal data flow error.</div><div>0:00:00.126812416 4114 0x14bbb0 WARN basesrc gstbasesrc.c:2865:gst_base_src_loop:<appsrc0> error: streaming task paused, reason not-negotiated (-4)</div><div>0:00:00.128321250 4114 0x14bbb0 WARN baseparse gstbaseparse.c:1153:gst_base_parse_sink_event_default:<parse> error: No valid frames found before end of stream</div><div>0:00:00.126777250 4114 0x139d20 DEBUG appsrc gstappsrc.c:1537:gst_app_src_push_buffer_full:<appsrc0> queueing buffer 0x1812a0</div><div>0:00:00.128696000 4114 0x139d20 DEBUG appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.128746333 4114 0x139d20 DEBUG appsrc gstappsrc.c:1502:gst_app_src_push_buffer_full:<appsrc0> queue filled (655360 >= 655360)</div><div>0:00:00.128783583 4114 0x139d20 DEBUG appsrc gstappsrc.c:1523:gst_app_src_push_buffer_full:<appsrc0> waiting for free space</div><div> </div><div> Thank you very much in advance.</div></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div>