stop image formation

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

stop image formation

prkhr4u
I am trying to take a snapshot and save it as a bitmap from a mjpg stream.
I am using the following command:

gst-launch-0.10 souphttpsrc location="http://169.254.75.39/video2.mjpg" ! jpegdec ! ffmpegcolorspace ! ffenc_bmp ! multifilesink location="abc.bmp"

When I run this command,it starts taking bitmap images and takes them continuously and doesn't stop. Along with abc.bmp, a temporary file "abc.bmp.WLQBBX(last name keeps changing)" is also formed.
I want to take snapshot only once and stop the process.
Reply | Threaded
Open this post in threaded view
|

Re: stop image formation

Sebastian Dröge-3
On Do, 2014-02-13 at 20:36 -0800, prkhr4u wrote:

> I am trying to take a snapshot and save it as a bitmap from a mjpg stream.
> I am using the following command:
>
> gst-launch-0.10 souphttpsrc location="http://169.254.75.39/video2.mjpg" !
> jpegdec ! ffmpegcolorspace ! ffenc_bmp ! multifilesink location="abc.bmp"
>
> When I run this command,it starts taking bitmap images and takes them
> continuously and doesn't stop. Along with abc.bmp, a temporary file
> "abc.bmp.WLQBBX(last name keeps changing)" is also formed.
> I want to take snapshot only once and stop the process.
gst-launch is just a debugging tool, it's not meant for writing
applications. I don't think you can do what you want with gst-launch,
but instead you'll have to write some code to do that. Should be
possible in a small Python script with just a few lines of code.

As an example look at the code of the totem video thumbnailer, but this
already does much much more than what you want to do:
https://git.gnome.org/browse/totem/tree/src/totem-video-thumbnailer.c

--
Sebastian Dröge, Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: stop image formation

prkhr4u
I have made a sample code like this:

GstElement *pipeline = gst_pipeline_new ("xvoverlay");
    GstElement *src = gst_element_factory_make ("souphttpsrc",NULL);
    GstElement *jpegdec = gst_element_factory_make("jpegdec",NULL);
    GstElement *ffmpeg= gst_element_factory_make("ffmpegcolorspace",NULL);
    GstElement *ffenc_bmp = gst_element_factory_make("ffenc_bmp",NULL);
    GstElement *sink = gst_element_factory_make ("multifilesink", NULL);

    gst_element_set_state(sink, GST_STATE_READY);

    gst_bin_add_many (GST_BIN (pipeline), src,jpegdec,ffmpeg,ffenc_bmp,sink, NULL);
    gst_element_link_many(src,jpegdec,ffmpeg,ffenc_bmp, sink);

    g_object_set (src, "location", "http://169.254.75.39/video2.mjpg", NULL);
    g_object_set (sink, "location", "abc.bmp", NULL);
   
    GstStateChangeReturn sret = gst_element_set_state (pipeline,
        GST_STATE_PLAYING);
    if (sret == GST_STATE_CHANGE_FAILURE) {
      gst_element_set_state (pipeline, GST_STATE_NULL);
      gst_object_unref (pipeline);
    }

But this code is not producing anything,nothing is happening.
What may be the possible reason?
I am able to play live stream and other gstreamer codes and everything is correctly setup.
Reply | Threaded
Open this post in threaded view
|

Re: stop image formation

Ian Davidson
Look at the 'Hello World' example in the gstreamer documentation
(http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-helloworld.html#section-helloworld).

You need to set up a loop (to tell the computer to twiddle its thumbs
while the pipeline is playing) and I suspect that you have missed that out.

Ian

On 15/02/2014 05:39, prkhr4u wrote:

> I have made a sample code like this:
>
> GstElement *pipeline = gst_pipeline_new ("xvoverlay");
>      GstElement *src = gst_element_factory_make ("souphttpsrc",NULL);
>      GstElement *jpegdec = gst_element_factory_make("jpegdec",NULL);
>      GstElement *ffmpeg= gst_element_factory_make("ffmpegcolorspace",NULL);
>      GstElement *ffenc_bmp = gst_element_factory_make("ffenc_bmp",NULL);
>      GstElement *sink = gst_element_factory_make ("multifilesink", NULL);
>
>      gst_element_set_state(sink, GST_STATE_READY);
>
>      gst_bin_add_many (GST_BIN (pipeline), src,jpegdec,ffmpeg,ffenc_bmp,sink,
> NULL);
>      gst_element_link_many(src,jpegdec,ffmpeg,ffenc_bmp, sink);
>
>      g_object_set (src, "location", "http://169.254.75.39/video2.mjpg",
> NULL);
>      g_object_set (sink, "location", "abc.bmp", NULL);
>      
>      GstStateChangeReturn sret = gst_element_set_state (pipeline,
>          GST_STATE_PLAYING);
>      if (sret == GST_STATE_CHANGE_FAILURE) {
>        gst_element_set_state (pipeline, GST_STATE_NULL);
>        gst_object_unref (pipeline);
>      }
>
> But this code is not producing anything,nothing is happening.
> What may be the possible reason?
> I am able to play live stream and other gstreamer codes and everything is
> correctly setup.
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/stop-image-formation-tp4665268p4665289.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> 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: stop image formation

prkhr4u
I have tried to insert a loop,but the loop is running continuously and hence no output is being displayed.
I only want to take 1 image and quit.
Here is how I have implemented:

    GMainLoop *loop;
    loop = g_main_loop_new (NULL, FALSE);

    GstElement *pipeline = gst_pipeline_new ("xvoverlay");
    GstElement *src = gst_element_factory_make ("souphttpsrc",NULL);
    g_object_set (src, "location", "http://169.254.126.124/video2.mjpg", NULL);
    GstElement *jpegdec = gst_element_factory_make("jpegdec",NULL);
    GstElement *ffmpeg= gst_element_factory_make("ffmpegcolorspace",NULL);
    GstElement *ffenc_bmp = gst_element_factory_make("ffenc_bmp",NULL);
    GstElement *sink = gst_element_factory_make ("multifilesink", NULL);
    g_object_set (sink, "location", "/home/hls/abc.bmp", NULL);
   
    g_main_loop_quit (loop);
    gst_element_set_state(sink, GST_STATE_READY);

    gst_bin_add_many (GST_BIN (pipeline), src,jpegdec,ffmpeg,ffenc_bmp,sink, NULL);
    gst_element_link_many(src,jpegdec,ffmpeg,ffenc_bmp, sink);    

    gst_element_set_state(pipeline,GST_STATE_PLAYING);

    g_main_loop_run (loop);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);    
    g_main_loop_unref (loop);

I do not want to add any message handler.
What is the correct loop order and how to run it?