[gst-devel] Video thumb nails
Michal Benes
michal.benes at itonis.tv
Wed Oct 18 09:30:45 CEST 2006
Hi Pavan,
your pipeline fails to change state to PAUSED,
gst_element_set_state(pipeline, GST_STATE_PAUSED) changes state
asynchronously. Use gst_element_get_state to wait until the state change
finishes. The problem is the queue between filesrc and decodebin (or
avidemux to be more precise). Queues work only in push-push mode (chain
mode) which is not supported by avidemux.
Michal
Pavan Kumar Patale píše v Út 17. 10. 2006 v 17:46 +0000:
> Hi,
>
> Thanks for the reply. I tried applying the solution but a blank png image
> comes up.
> Seek does not seem to be happening correctly. Have, appended the code. Can
> you
> pls let me know if i am missing something in it.
>
> Thanks,
> Pavan.
>
> >
> >I just wanted to note that you may need to turn on these signals by
> >setting the fakesink's signal-handoffs property to true.
> >~Scott
> >
> >Michal Benes wrote:
> > >> Can anyone pls let me know if there is any support from GStreamer
> >framework
> > >> to create thumb nails for video files.
> > >
> > > Hi,
> > >
> > > it is not difficult. Just create a pipe
> > >
> > > filesrc location=source ! decodebin ! ffmpegcolorspace ! pngenc !
> > > fakesink
> > >
> > > and connect to fakesink's preroll-handoff signal. Then put the pipeline
> > > to PAUSED state (not PLAYING) and seek to the desired position. Fakesink
> > > will give you png screenshot in preroll-handoff callback. Of course you
> > > can put videoscale before pngenc to obtain the desired resolution.
> > >
> > > Michal
> > >
>
>
> #include <glib.h>
> #include <gst/gst.h>
>
> static GstElement *pipeline = NULL;
> static GMainLoop *loop = NULL;
> static GstElement *fsink = NULL;
> static GError *error = NULL;
>
> static void preroll_handoff_cb(GstElement * object,
> GstBuffer * buffer,
> GstPad * pad, gpointer user_data)
> {
> g_print("Starts %s\n", __FUNCTION__);
> FILE *fp = NULL;
> fp = fopen("tnail.png", "wb");
> fwrite(buffer->data, buffer->size, 1, fp);
> fclose(fp);
> g_print("Ends %s\n", __FUNCTION__); }
>
> gint main(gint argc, gchar * argv[])
> {
> gst_init(&argc, &argv);
>
> loop = g_main_loop_new(NULL, TRUE);
>
> pipeline = gst_parse_launch ("filesrc location=1.avi ! queue !
> decodebin ! ffmpegcolorspace ! pngenc ! fakesink name=fsink", &error);
>
> if (!pipeline) {
> g_print("Unable to get the pipeline\n");
> return -1;
> }
>
> if (error) {
> g_print("Error %s\n", error->message);
> g_error_free(error);
> error = NULL;
> return -1;
> }
>
> fsink = gst_bin_get_by_name(GST_BIN(pipeline), "fsink");
>
> g_object_set(G_OBJECT(fsink), "signal-handoffs", TRUE, NULL);
>
> g_signal_connect(G_OBJECT(fsink), "preroll-handoff",
> preroll_handoff_cb, NULL);
>
> if (!gst_element_set_state(pipeline, GST_STATE_PAUSED)) {
> g_print("Unable to set the state to paused\n");
> }
> if (!gst_element_seek_simple(fsink, GST_FORMAT_BYTES,
> GST_SEEK_FLAG_ACCURATE, 0)) {
> g_print("Unable to seek\n");
> }
>
> g_print("Inside loop\n");
> g_main_loop_run(loop);
> return 0;
> }
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list