On Tue, Nov 20, 2012 at 11:03 AM, charles quarra
<[email protected]> wrote:
> Hi,
>
> this ML seems a bit inactive, but i thought to take a shot and see if
> there is still life :)
>
> i need a method to capture the pixel images of one or more windows
> (the programmatic equivalent of alt-print screen in windows) running
> on a X11 diplay. The `import` command line sort of half-does it, but
> it is very slow, and i need this for screen capturing, so it needs to
> be done ideally at the very least 10-20 frames per sec.
>
> Further requirements:
>
> 1) Even if a new window is placed on top of the window that is being
> captured, the pixel image should still point to the original
> application window without any occlusion
>
> 2) it is not needed that the application window to be seen by the
> user, i just need to store the pixel buffers/images for video purposes
>
>
> Any ideas if i can achieve this in some form with compiz manager?

You can achieve this from within compiz but there's not a whole lot of
point from doing it within compiz.

All you'll need to do is grab the offscreen window pixmap and dump it
every X ms. For example, this not-tested pseudocode should be on the
right track:

int main (...)
{
    /* get window id */
    Window id = passed_window_id;

    Display *dpy = XOpenDisplay (NULL);

    XCompositeQueryExtension (...);
    XDamageQueryExtension (..., &damageBase);

    Damage damage = XDamageCreate (dpy, id, XDamageReportRawRectangles);

    XCompositeRedirectWindow (dpy, id, CompositeRedirectAutomatic);

    XEvent ev;

    while (XNextEvent (&ev))
    {
        switch (ev.type)
        {
        case damageBase + XDamageNotify:
            XDamageEvent *de = (XDamageEvent) &ev;
            Pixmap p = XCompositeNameWindowPixmap (dpy, id);
            /* Use any image manipulation library to pull the contents
out of the pixmap
             * as specified by the "area" member in the XDamageEvent */
            XFreePixmap (p);
        default:
            break;
        }
    }

    XCompositeUnredirectWindow (dpy, id);
    XDamageDestroy (dpy, damage);
    return 0;
}

>
> other alternatives that i've explored are:
>
> 1) xvfb - it works but it does does CPU rendering, which is slow and
> wasteful of a good GPU
> 2) x11 inside many lxc - theoretically could work but is complex to
> setup, and i'm not sure it will scale well with many windows being
> captured
>
> suggestions and ideas are welcome
> _______________________________________________
> dev mailing list
> [email protected]
> http://lists.compiz.org/mailman/listinfo/dev



-- 
Sam Spilsbury
_______________________________________________
dev mailing list
[email protected]
http://lists.compiz.org/mailman/listinfo/dev

Reply via email to