Re: [GtkGLExt] capturing video clips



transcode is a command line utility and I need a function in a library
- I need my program to be also platform independent so I can compile
it also under Windows :(
since I use vtk for visualization I can use its facilities for
capturing video... I just preferred to do everything through gtk but
it is also a solution.

thanks...

On Tue, Feb 26, 2008 at 1:07 AM, cbeau <cbeauc gmail com> wrote:
> I am capturing my GL surface to a movie file using an open-source movie
> encoder called "transcode" and getting the pixel data with a call to
> "gdk_pixbuf_get_from_drawable" and then "piping" that data through an open
> pipe to transcode. Please find the code for my program attached. I have to
> warn you though: the code is a bit messy. The important bits are mainly:
>
> ---------------------------------------
>
> length += sprintf( movie_command, "transcode -i /dev/fd/0 --use_rgb -x
> raw,null -g %dx%d -o \"%s\" -f %d -w %d ", scapture.enc_width,
> scapture.enc_height, gtk_entry_get_text(GTK_ENTRY(scapture.movie_name)),
> nfps, nkbps );
>
> length += sprintf(movie_command+length, "-y xvid,null");
>
> scapture.pipe = popen( movie_command, "w" );
>
> Then, on every refresh of the screen (every step of my simulation), I do:
>
>  screenshot = gdk_pixbuf_get_from_drawable( screenshot,
> GDK_DRAWABLE(GTK_WIDGET(image)->window), gdk_colormap_get_system(), 0, 0, 0,
> 0, scapture.enc_width, scapture.enc_height );
>
> fwrite( gdk_pixbuf_get_pixels(GDK_PIXBUF(screenshot)),
> gdk_pixbuf_get_rowstride(GDK_PIXBUF(screenshot)),
> gdk_pixbuf_get_height(GDK_PIXBUF(screenshot)), scapture.pipe );
>
> And when I'm done, I do
>
> pclose( scapture.pipe );
>
> By the way:
>
>  GtkWidget *image;
>  image = gtk_drawing_area_new();
>  gtk_widget_set_size_request( GTK_WIDGET(image), 100, 100);
>  g_signal_connect(GTK_OBJECT(image), "expose_event",
> G_CALLBACK(expose_arena), NULL);
>  gtk_widget_set_gl_capability( image, glconfig, NULL, FALSE,
> GDK_GL_RGBA_TYPE );
>
> ---------------------------------------------
>
> The real issue with this which is also an issue for taking screenshots, is
> that the obscured parts of an onscreen widget like a gtk_drawing_area will
> have "junk" in them (not get rendered) and so there will be junk in your
> captured image/movie. For example, I'd go for a coffee, my screensaver would
> kick in and my encoder would record nothing but junk.
>
> To prevent this, it is good to switch to using an offscreen widget. For
> example, use a GtkImage to display an offscreen "GdkPixmap" and render your
> OpenGL scenes to the GdkPixmap. This way, the GdkPixmap is always fully
> rendered because it is offscreen and "captures" of the GdkPixmap (NOT THE
> GtkImage) are always right regardless of whether GtkImage is fully rendered
> or not. However, I have had tones of troubles getting GdkPixmap rendering to
> work and it still doesn't work on many graphics card (offscreen rendering
> not working well at all!). If you are using a GdkPixmap, then the
> corresponding call above would be replaced by:
>
> ---------------------------------------
>
> screenshot = gdk_pixbuf_get_from_drawable( screenshot, GDK_DRAWABLE(pixmap),
> gdk_colormap_get_system(), 0, 0, 0, 0, scapture.enc_width,
> scapture.enc_height );
>
> Where:
>
> GdkPixmap *pixmap;
> pixmap = gdk_pixmap_new( NULL, width, height,
> gdk_gl_config_get_depth(glconfig) );
> glpixmap = gdk_pixmap_set_gl_capability( pixmap, glconfig, NULL );
> gtk_image_set_from_pixmap( GTK_IMAGE(image), pixmap, NULL );
>
> -----------------------------------------
>
> If you want to download the full program to try it out and get a better feel
> for how the code relates the the actual GUI, then feel free to download
> from:
>
> http://masyv.sourceforge.net
>
> Cheers,
> cbeau.
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]