Hi, I am new to this forum. I am trying to pull frames from gstreamer pipeline and feed it to user application. I am using appsink pad to pull out the frames while the pipeline is in the PLAYING state. Problem: 1. The gst_app_sink_pull_sample(), gst_sample_get_buffer() and gst_buffer_map() hands out only streams which are of size 4096 bytes each. I tried changing the blocksize but, there is no effect. My goal: To extract or pull a single frame into a single buffer and feed this buffer as input to my application which does some image processing (I am not using OpenCV). I want to pull every frame from the video-source, populate the buffer (each frame is associated with a particular buffer) and finally feed the buffer to my application. I don't want to dump this frame into a file in my filesystem. Questions: 1. Are there any other ways in which I can achieve my goal without using appsink? 2. If using appsink is the only way I can pull data from gstreamer, how can I achieve my goal using appsink? I appreciate any guidance. Thanks in advance. Kiran _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi, I think you are mistaken when you say “The gst_app_sink_pull_sample(),
gst_sample_get_buffer() and gst_buffer_map() hands out only streams which are of size 4096 bytes each”.
I am using these APIs to pass full 1920 * 1080 frames. You should provide more details so that we can maybe see what is going wrong. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Hi, I am new to this forum. I appreciate any guidance. _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi, Sorry for the confusion. Even I am able to pass full 1920x1080 frames. But, GstMapInfo map; gst_buffer_map(buffer, &map, GST_MAP_READ); Here, the size of "map.data" which is "map.size" will always be 4096 bytes for each chunk of data (I get multiple chunks, so that the entire frame is streamed). How to increase this chunk size? So that I get more data in a single chunk itself. For example if a video frame is 512x512x8 (bit depth)=2097152 bits. And at the appsink I don't want 4096 bytes to be transferred 64 times to transfer the entire frame. I want 2097152 bits to be available in a single shot at appsink so that I can copy this data in a buffer of size 2097152 bits and pass this buffer to my application for image processing. One of the filter which I am using in my image processing application needs the entire frame as its input and not in the form of chunks. Or, is there a way in which I can accumulate these chunks into a single buffer? In case of a video sequence each frame needs to be associated with a particular buffer. Thanks, Kiran On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by Thornton, Keith
Hi, I have attached the log file. PFA for the same.On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel log.txt (5K) Download Attachment |
In reply to this post by Thornton, Keith
I also used gst_base_sink_set_blocksize() to set the blocksize when the sink is in pull mode. Nothing changed. Thanks, Kiran On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi,
I don’t know what you are doing but when I call gst_buffer_map for my Full HD frames, I get info.size=8294400 and one single block of memory which I can copy in
a single operation. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar I also used gst_base_sink_set_blocksize() to set the blocksize when the sink is in pull mode. Nothing changed. Thanks, Kiran On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote: Hi, I think you are mistaken when you say “The
gst_app_sink_pull_sample(), gst_sample_get_buffer() and gst_buffer_map() hands out only streams which are of size 4096 bytes each”.
I am using these APIs to pass full 1920 * 1080 frames. You should provide more details so that we can maybe see what is going wrong. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Hi, I am new to this forum. I appreciate any guidance.
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi, Are you setting the size in your code? On Tue, Jun 14, 2016 at 10:46 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I am not setting the size in my SampleCallback function but I am setting the size (and type of memory i.e.contiguous) where I provide the buffers to my grabber
card. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Hi, Are you setting the size in your code? On Tue, Jun 14, 2016 at 10:46 PM, Thornton, Keith <[hidden email]> wrote: Hi,
I don’t know what you are doing but when I call gst_buffer_map for my Full HD frames, I get info.size=8294400
and one single block of memory which I can copy in a single operation. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar I also used gst_base_sink_set_blocksize() to set the blocksize when the sink is in pull mode. Nothing changed. Thanks, Kiran On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote: Hi, I think you are mistaken when you say “The
gst_app_sink_pull_sample(), gst_sample_get_buffer() and gst_buffer_map() hands out only streams which are of size 4096 bytes each”.
I am using these APIs to pass full 1920 * 1080 frames. You should provide more details so that we can maybe see what is going wrong. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Hi, I am new to this forum. I appreciate any guidance.
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Can you please explain me how you are doing this? I'm trying this from past 5 days. On Tue, Jun 14, 2016 at 11:05 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
The API I am using to provide the buffers to my grabber card is proprietary to the grabber card so that won’t help you much I am then creating a gst_buffer using Gst_buffer_new_wrapped(GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS, bufferAddress, bufferSize, 0, bufferUsedSize, freeAdress, freeFunction); (the last two parameters are needed because the buffer has to be returned to the grabber card’s queue when the pipeline has finished with it) Which takes the existing data and wraps it in a gst_buffer before calling gst_app_src_push_buffer.
Maybe you can achieve something here. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Can you please explain me how you are doing this? I'm trying this from past 5 days. On Tue, Jun 14, 2016 at 11:05 PM, Thornton, Keith <[hidden email]> wrote: I am not setting the size in my SampleCallback function but I am setting the size (and type of memory
i.e.contiguous) where I provide the buffers to my grabber card. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar
Hi, Are you setting the size in your code? On Tue, Jun 14, 2016 at 10:46 PM, Thornton, Keith <[hidden email]> wrote: Hi,
I don’t know what you are doing but when I call gst_buffer_map for my Full HD frames, I get info.size=8294400
and one single block of memory which I can copy in a single operation. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar I also used gst_base_sink_set_blocksize() to set the blocksize when the sink is in pull mode. Nothing changed. Thanks, Kiran On Mon, Jun 13, 2016 at 10:51 PM, Thornton, Keith <[hidden email]> wrote: Hi, I think you are mistaken when you say “The
gst_app_sink_pull_sample(), gst_sample_get_buffer() and gst_buffer_map() hands out only streams which are of size 4096 bytes each”.
I am using these APIs to pass full 1920 * 1080 frames. You should provide more details so that we can maybe see what is going wrong. Von: gstreamer-devel [mailto:[hidden email]]
Im Auftrag von Kiran Kumar Hi, I am new to this forum. I appreciate any guidance.
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Thank you very much. I will try this. On Tue, Jun 14, 2016 at 11:24 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by Thornton, Keith
Hi, Since I am getting the input from filesrc, I had to change the blocksize of filesrc. Now it is working according to my requirements. Thank you very much for your inputs :) On Tue, Jun 14, 2016 at 11:24 PM, Thornton, Keith <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Hi Kiran,
I am facing the same problem. Instead of filesrc i am using rtpsrc... Sharing the code Can you guide on me this. I want frames of size 1280x720x3 #include <gst/gst.h> #include <stdio.h> #include <signal.h> #include <stdlib.h> #include <iostream> #include <unistd.h> #include "opencv2/opencv.hpp" #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> GstElement *pipeline; GstBus *bus; GstMessage *msg; using namespace cv; static GstFlowReturn have_frame (GstElement * appsink, gpointer app) { GstBuffer *buffer; GstSample *sample; /* get the buffer, we can also wakeup the mainloop to get the subtitle from * appsink in the mainloop */ g_signal_emit_by_name (appsink, "pull-sample", &sample); static int framecount = 0; if (sample) { GstMapInfo map; gint64 position; GstClock *clock; GstClockTime base_time, running_time; buffer = gst_sample_get_buffer (sample); gst_element_query_position (appsink, GST_FORMAT_TIME, &position); clock = gst_element_get_clock (appsink); base_time = gst_element_get_base_time (appsink); running_time = gst_clock_get_time (clock) - base_time; gst_object_unref (clock); if (gst_buffer_map(buffer, &map, GST_MAP_READ)) { printf("Count %d\n",framecount); g_print("Appsink: Buffer Received: Content = %u\n", map.size); Mat frame(Size(1280, 720), CV_8UC3, (char*)map.data, Mat::AUTO_STEP); //if its a 320x240 size image imwrite("./Result/XYZ.jpg",frame); printf("Writing image file \n"); } // gst_util_dump_mem (map.data, map.size); gst_buffer_unmap (buffer, &map); gst_sample_unref (sample); framecount++; } return GST_FLOW_OK; } int main(int argc, char *argv[]) { /* Initialize GStreamer */ gst_init (&argc, &argv); /* Build the pipeline */ pipeline = gst_parse_launch ("rtspsrc location=rtsp://URL !" "rtph264depay !" "h264parse !" "v4l2h264dec !" "v4l2h264enc !" "h264parse !" "queue !" "appsink name=appsink", NULL); GstElement *sink = gst_bin_get_by_name(GST_BIN(pipeline), "appsink"); if (!sink) { printf("sink is NULL\n"); exit(1); } g_object_set (G_OBJECT (sink), "emit-signals", TRUE, NULL); g_signal_connect (sink, "new-sample", G_CALLBACK (have_frame),NULL); /* Start playing */ gst_element_set_state (pipeline, GST_STATE_PLAYING); /* Wait until error or EOS */ bus = gst_element_get_bus (pipeline); msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,static_cast<GstMessageType>( GST_MESSAGE_ERROR | GST_MESSAGE_EOS)); /* Parse message */ if (msg != NULL) { GError *err; gchar *debug_info; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ERROR: gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); break; case GST_MESSAGE_EOS: g_print ("End-Of-Stream reached.\n"); break; default: /* We should not reach here because we only asked for ERRORs and EOS */ g_printerr ("Unexpected message received.\n"); break; } gst_message_unref (msg); } /* Free resources */ if (msg != NULL) gst_message_unref (msg); gst_object_unref (bus); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline); return 0; } Looking for help. Thanks -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |