[gst-devel] Video thumb nails
Scott Shawcroft
shux_linux at comcast.net
Tue Oct 17 21:55:23 CEST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Pavan,
I'm not sure what it is. Attached is my python code.
~Scott
Pavan Kumar Patale wrote:
> 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;
> }
>
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFNTUq10ekhar8gdURAkLuAJ9cPAJfIQVTiaBxmILZVxbyXwkkOwCghCb6
IQxfMwUskQ1yVPY30SG1FYA=
=lBQC
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pull_thumbnails.py
Type: text/x-python
Size: 3574 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20061017/e1d92f01/attachment.py>
More information about the gstreamer-devel
mailing list