Hi all.
I'm new to gstreamer. Maybe my question is quite easy or stupid. I would like to know the easiest way how to get frames from rtsp video stream to, for example, store them to files as jpeg/png/bmp etc. I need to use it from C/C++ code. Thanks in advance. _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Use appsink element to receive the frame and save it in .jpg format using opencv: For eg. GstElement *pipeline = gst_parse_launch ("rtspsrc location=rtsp://address ! YOUR CODEC ! appsink name=sink", &error); GstElement *sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); GstAppSink *appsink = GST_APP_SINK(sink); GstSample *sample = gst_app_sink_pull_sample(appsink); GstBuffer *buffer = gst_sample_get_buffer(sample); GstMapInfo map; gst_buffer_map (buffer, &map, GST_MAP_READ); Mat frame(Size(320, 240), CV_8UC3, (char*)map.data, Mat::AUTO_STEP); if its a 320x240 size image imwrite("XYZ.jpg",frame); On Thu, May 26, 2016 at 3:19 PM, Alexander Soloviev <[hidden email]> wrote:
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I think using a combination of jpegenc and multifilesink is more light-weight than bringing OpenCV into the equation.
|
In reply to this post by akash jain
Hi,
I am trying to integrate the code sample into my project; but I get an error about appsink: GstAppSink *appsink = GST_APP_SINK(*NULL*); do not get any link errors but GstAppSink *appsink = GST_APP_SINK(*sink*); does error: undefined reference to `gst_app_sink_get_type' Do i need to link any other libraries other than gstreamer? Can you help me with this issue? My system: Ubuntu 16.04 Qt Creator 5.9.1 gstplugins-good , glstreamer packages installed akash jain wrote > Use appsink element to receive the frame and save it in .jpg format using > opencv: > > For eg. > > GstElement *pipeline = gst_parse_launch ("rtspsrc location=rtsp://address > ! > YOUR CODEC ! appsink name=sink", &error); > > GstElement *sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); > > GstAppSink *appsink = GST_APP_SINK(sink); > > GstSample *sample = gst_app_sink_pull_sample(appsink); > > GstBuffer *buffer = gst_sample_get_buffer(sample); > > GstMapInfo map; > > gst_buffer_map (buffer, &map, GST_MAP_READ); > > Mat frame(Size(320, 240), CV_8UC3, (char*)map.data, Mat::AUTO_STEP); if > its a 320x240 size image > > imwrite("XYZ.jpg",frame); > > > > > > > > > On Thu, May 26, 2016 at 3:19 PM, Alexander Soloviev < > alexolut@ > > > wrote: > >> Hi all. >> >> I'm new to gstreamer. Maybe my question is quite easy or stupid. >> >> I would like to know the easiest way how to get frames from rtsp video >> stream to, for example, store them to files as jpeg/png/bmp etc. >> >> I need to use it from C/C++ code. >> >> Thanks in advance. >> >> _______________________________________________ >> gstreamer-devel mailing list >> > gstreamer-devel@.freedesktop >> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel >> >> > > _______________________________________________ > gstreamer-devel mailing list > gstreamer-devel@.freedesktop > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Yes, you need to link against an additional library to use AppSink/AppSrc stuff. If your app is Makefile based the easiest way to do this is by using pkg-config. Something like:
LIBS+=`pkg-config --libs gstreamer-app-1.0` — Michael Gruner <[hidden email]> Embedded Linux and GStreamer solutions RidgeRun Engineering Contact Us - http://www.ridgerun.com/#!contact/c3vn
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Thanks, the errors are gone now. However I need help with another issue now.
Using the code fragment above, I want to write a C++ program that gets RTSP stream frames and put it in openCV mat. Below is my code. I get an error when trying to get a sample from the appsink. I highlighted the code step bold. Do you have any idea how to get the sample from appsink? #include <gst/gst.h> #include <opencv2/opencv.hpp> #include <gstappsink.h> #ifdef HAVE_GTK #include <gtk/gtk.h> #include <gdk-pixbuf/gdk-pixbuf.h> #endif #include <stdlib.h> int main (int argc, char *argv[]) { GstElement *pipeline; gint width, height; gchar *descr; GError *error = NULL; gint64 duration, position; GstStateChangeReturn ret; gboolean res; GstBus *bus; GstMessage *msg; gst_init (0, NULL); pipeline = gst_parse_launch ("rtspsrc location=rtsp://admin:admin@192.168.1.109:554/stream1 latency=0 ! decodebin ! appsink name=sink ",NULL); GstElement *sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); if(!sink){ printf("sink is NULL\n"); exit(1); } GstAppSink *appsink = GST_APP_SINK(sink); if(!appsink){ printf("appsink is NULL\n"); exit(1); } * GstSample *sample = gst_app_sink_pull_sample(appsink);* if(!sample){ printf("sample is NULL\n"); exit(1); } GstBuffer *buffer = gst_sample_get_buffer(sample); GstMapInfo map; gst_buffer_map (buffer, &map, GST_MAP_READ); cv::Mat frame(cv::Size(320, 240), CV_8UC3, (char*)map.data, cv::Mat::AUTO_STEP); imwrite("XYZ.jpg",frame); } -- 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 |