static void check_cover_for_stream (ThumbApp *app, const char *signal_name) { GdkPixbuf *pixbuf; GstTagList *tags = NULL; g_signal_emit_by_name (G_OBJECT (app->play), signal_name, 0, &tags); if (!tags) return; pixbuf = xplayer_gst_tag_list_get_cover (tags); if (!pixbuf) { gst_tag_list_unref (tags); return; } PROGRESS_DEBUG("Saving cover image"); thumb_app_cleanup (app); save_pixbuf (pixbuf, app->output, app->input, output_size, TRUE); g_object_unref (pixbuf); exit (0); }
static void on_got_metadata_event (BaconVideoWidget *bvw, callback_data *data) { GValue value = { 0, }; GdkPixbuf *pixbuf; PROGRESS_DEBUG("Got metadata, checking if we have a cover"); bacon_video_widget_get_metadata (bvw, BVW_INFO_COVER, &value); pixbuf = g_value_dup_object (&value); g_value_unset (&value); if (pixbuf) { PROGRESS_DEBUG("Saving cover image"); bacon_video_widget_close (bvw); totem_resources_monitor_stop (); gtk_widget_destroy (GTK_WIDGET (bvw)); save_pixbuf (pixbuf, data->output, data->input, output_size, TRUE); g_object_unref (pixbuf); exit (0); } else if (has_video (bvw) == FALSE) { PROGRESS_DEBUG("No covers, and no video, exiting"); exit (0); } }
static void i_mousedown(void* widget, GdkEventButton *event, gpointer data) { sx = event->x; sy = event->y; drawing = true; save_pixbuf(); /*printf("mouse down %d %d \n",sx,sy);*/ }
int main(int argc, char **argv) { GdkPixbuf *pixbuf; GnomeThemeMetaInfo *theme; GnomeVFSURI *uri; g_thread_init (NULL); theme_thumbnail_factory_init (argc, argv); if (argc != 3) { g_printerr ("usage: gnome-theme-thumbnailer theme output-image\n"); return 1; } if (!gnome_vfs_init ()) { g_printerr ("could not initialise gnome-vfs\n"); return 1; } uri = gnome_vfs_uri_new (argv[1]); theme = gnome_theme_read_meta_theme (uri); gnome_vfs_uri_unref (uri); if (theme) { pixbuf = generate_meta_theme_thumbnail (theme); gnome_theme_meta_info_free (theme); if (pixbuf) { save_pixbuf (pixbuf, argv[2]); gdk_pixbuf_unref (pixbuf); } else { g_printerr ("could not generate thumbnail\n"); return 1; } } else { g_printerr ("usage: gnome-theme-thumbnailer theme output-image\n"); return 1; } return 0; }
int main (int argc, char *argv[]) { GOptionGroup *options; GOptionContext *context; GError *err = NULL; GdkPixbuf *pixbuf; const char *input, *output; ThumbApp app; context = g_option_context_new ("Thumbnail movies"); options = gst_init_get_option_group (); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, options); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) { g_print ("couldn't parse command-line options: %s\n", err->message); g_error_free (err); return 1; } #ifdef G_OS_UNIX if (time_limit != FALSE) { errno = 0; if (nice (20) != 20 && errno != 0) g_warning ("Couldn't change nice value of process."); } #endif if (print_progress) { fcntl (fileno (stdout), F_SETFL, O_NONBLOCK); setbuf (stdout, NULL); } if (g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } if (raw_output == FALSE && output_size == -1) output_size = DEFAULT_OUTPUT_SIZE; if (filenames == NULL || g_strv_length (filenames) != 2 || (second_index != -1 && gallery != -1) || (print_progress == TRUE && verbose == TRUE)) { char *help; help = g_option_context_get_help (context, FALSE, NULL); g_print ("%s", help); g_free (help); return 1; } input = filenames[0]; output = filenames[1]; PROGRESS_DEBUG("Initialised libraries, about to create video widget"); PRINT_PROGRESS (2.0); app.input = input; app.output = output; thumb_app_setup_play (&app); thumb_app_set_filename (&app); PROGRESS_DEBUG("Video widget created"); PRINT_PROGRESS (6.0); if (time_limit != FALSE) xplayer_resources_monitor_start (input, 0); PROGRESS_DEBUG("About to open video file"); if (thumb_app_start (&app) == FALSE) { g_print ("xplayer-video-thumbnailer couldn't open file '%s'\n", input); exit (1); } thumb_app_set_error_handler (&app); /* We don't need covers when we're in gallery mode */ if (gallery == -1) thumb_app_check_for_cover (&app); if (thumb_app_get_has_video (&app) == FALSE) { PROGRESS_DEBUG ("xplayer-video-thumbnailer couldn't find a video track in '%s'\n", input); exit (1); } thumb_app_set_duration (&app); PROGRESS_DEBUG("Opened video file: '%s'", input); PRINT_PROGRESS (10.0); if (gallery == -1) { /* If the user has told us to use a frame at a specific second * into the video, just use that frame no matter how boring it * is */ if (second_index != -1) { assert_duration (&app); pixbuf = capture_frame_at_time (&app, second_index * 1000); } else { pixbuf = capture_interesting_frame (&app); } PRINT_PROGRESS (90.0); } else { assert_duration (&app); /* We're producing a gallery of screenshots from throughout the file */ pixbuf = create_gallery (&app); } /* Cleanup */ xplayer_resources_monitor_stop (); thumb_app_cleanup (&app); PRINT_PROGRESS (92.0); if (pixbuf == NULL) { g_print ("xplayer-video-thumbnailer couldn't get a picture from '%s'\n", input); exit (1); } PROGRESS_DEBUG("Saving captured screenshot"); save_pixbuf (pixbuf, output, input, output_size, FALSE); g_object_unref (pixbuf); PRINT_PROGRESS (100.0); return 0; }
int main (int argc, char *argv[]) { GOptionGroup *options; GOptionContext *context; GError *err = NULL; BaconVideoWidget *bvw; GdkPixbuf *pixbuf; const char *input, *output; callback_data data; g_thread_init (NULL); context = g_option_context_new ("Thumbnail movies"); options = bacon_video_widget_get_option_group (); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, options); #ifndef THUMB_DEBUG g_type_init (); #else g_option_context_add_group (context, gtk_get_option_group (TRUE)); #endif if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) { g_print ("couldn't parse command-line options: %s\n", err->message); g_error_free (err); return 1; } #ifdef G_OS_UNIX if (time_limit != FALSE) { errno = 0; if (nice (20) != 20 && errno != 0) g_warning ("Couldn't change nice value of process."); } #endif if (print_progress) { fcntl (fileno (stdout), F_SETFL, O_NONBLOCK); setbuf (stdout, NULL); } if (g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } if (raw_output == FALSE && output_size == -1) output_size = DEFAULT_OUTPUT_SIZE; if (filenames == NULL || g_strv_length (filenames) != 2 || (second_index != -1 && gallery != -1) || (print_progress == TRUE && verbose == TRUE)) { char *help; help = g_option_context_get_help (context, FALSE, NULL); g_print ("%s", help); g_free (help); return 1; } input = filenames[0]; output = filenames[1]; PROGRESS_DEBUG("Initialised libraries, about to create video widget"); PRINT_PROGRESS (2.0); bvw = BACON_VIDEO_WIDGET (bacon_video_widget_new (-1, -1, BVW_USE_TYPE_CAPTURE, &err)); if (err != NULL) { g_print ("totem-video-thumbnailer couldn't create the video " "widget.\nReason: %s.\n", err->message); g_error_free (err); exit (1); } data.input = input; data.output = output; g_signal_connect (G_OBJECT (bvw), "got-metadata", G_CALLBACK (on_got_metadata_event), &data); PROGRESS_DEBUG("Video widget created"); PRINT_PROGRESS (6.0); if (time_limit != FALSE) totem_resources_monitor_start (input, 0); PROGRESS_DEBUG("About to open video file"); if (bacon_video_widget_open (bvw, input, NULL, &err) == FALSE) { g_print ("totem-video-thumbnailer couldn't open file '%s'\n" "Reason: %s.\n", input, err->message); g_error_free (err); exit (1); } PROGRESS_DEBUG("Opened video file: '%s'", input); PRINT_PROGRESS (10.0); if (gallery == -1) { /* If the user has told us to use a frame at a specific second * into the video, just use that frame no matter how boring it * is */ if (second_index != -1) pixbuf = capture_frame_at_time (bvw, input, output, second_index); else pixbuf = capture_interesting_frame (bvw, input, output); PRINT_PROGRESS (90.0); } else { /* We're producing a gallery of screenshots from throughout the file */ pixbuf = create_gallery (bvw, input, output); } /* Cleanup */ bacon_video_widget_close (bvw); totem_resources_monitor_stop (); gtk_widget_destroy (GTK_WIDGET (bvw)); PRINT_PROGRESS (92.0); if (pixbuf == NULL) { g_print ("totem-video-thumbnailer couldn't get a picture from " "'%s'\n", input); exit (1); } PROGRESS_DEBUG("Saving captured screenshot"); save_pixbuf (pixbuf, output, input, output_size, FALSE); g_object_unref (pixbuf); PRINT_PROGRESS (100.0); return 0; }
int main (int argc, char *argv[]) { GOptionGroup *options; GOptionContext *context; GError *err = NULL; GdkPixbuf *pixbuf; const char *input, *output; ThumbApp app; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new ("Thumbnail movies"); options = gst_init_get_option_group (); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, options); if (g_option_context_parse (context, &argc, &argv, &err) == FALSE) { g_print ("couldn't parse command-line options: %s\n", err->message); g_error_free (err); return 1; } fcntl (fileno (stdout), F_SETFL, O_NONBLOCK); setbuf (stdout, NULL); if (raw_output == FALSE && output_size == -1) output_size = DEFAULT_OUTPUT_SIZE; if (filenames == NULL || g_strv_length (filenames) != 2 || (second_index != -1 && gallery != -1)) { char *help; help = g_option_context_get_help (context, FALSE, NULL); g_print ("%s", help); g_free (help); return 1; } input = filenames[0]; output = filenames[1]; g_debug("Initialised libraries, about to create video widget"); PRINT_PROGRESS (2.0); app.input = input; app.output = output; thumb_app_setup_play (&app); thumb_app_set_filename (&app); g_debug("Video widget created"); PRINT_PROGRESS (6.0); g_debug("About to open video file"); if (thumb_app_start (&app) == FALSE) { g_print ("totem-video-thumbnailer couldn't open file '%s'\n", input); exit (1); } thumb_app_set_error_handler (&app); if (thumb_app_get_has_video (&app) == FALSE) { g_debug ("totem-video-thumbnailer couldn't find a video track in '%s'\n", input); exit (1); } thumb_app_set_duration (&app); g_debug("Opened video file: '%s'", input); PRINT_PROGRESS (10.0); assert_duration (&app); /* We're producing a gallery of screenshots from throughout the file */ pixbuf = create_gallery (&app); /* Cleanup */ thumb_app_cleanup (&app); PRINT_PROGRESS (92.0); if (pixbuf == NULL) { g_print ("totem-video-thumbnailer couldn't get a picture from '%s'\n", input); exit (1); } g_debug("Saving captured screenshot to %s", output); save_pixbuf (pixbuf, output, input, output_size, FALSE); g_object_unref (pixbuf); PRINT_PROGRESS (100.0); return 0; }