laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 258 forks source link

How to hide the slimerjs logo from video recordings? #635

Open matteoraggi opened 7 years ago

matteoraggi commented 7 years ago

versions

Steps to reproduce the issue

Hi Friends, I'm trying to record a web page running a video using slimerjs in server side where I have no real display

So I used the Xvfb as the display, Now, my problem is in the video I can see the slimerjs logo but in my local I could take the webpage on top using page.evaluate(function () { window.focus(); });

But in the server side the slimerjs logo still shows in the video recorded Please help me to discover how to get rid of this issue. Below are the commands of the script that I am using:

///Using X11grab Xvfb :99 -screen 0 1080x1920x24 -ac & export DISPLAY=:99 ./slimerjs hello.js --debug=true

Step#1: ffmpeg records a mpg video from the x11grab ffmpeg -y -s 1080x1920 -f x11grab -r 25 -i :99.0+0,0 -r 25 -c:v mpeg2video -q:v 0 output.mpg

Step#2: we just convert the mpg into mp4 ffmpeg -y -i output.mpg -c:v libx264 -pix_fmt yuv420p -movflags +faststart paelli.mp4

Final video in here http://185.24.234.250/Recording-Website-PhantomJS-and-FFMpeg/paelli.mp4

slimer script hello.js

var page = require('webpage').create();
page.viewportSize = { width:1080, height:1920 };
page.open("http://185.24.234.250/Recording-Website-PhantomJS-and-FFMpeg/paella/paella.html")
    .then(function(status){
         if (status == "success") {
            page.evaluate(function () {
                window.focus();
            });
         }
     });

Actual results:

Expected results:

plonknimbuzz commented 7 years ago

i cant see your video. is your video still exists?

matteoraggi commented 7 years ago

no, I deleted it..

zhuyifei1999 commented 4 years ago

This can't-be-simpler window manager will make focus possible:

#include <X11/Xlib.h>

int main() {
    Display *dpy;
    Window root;
    XEvent ev;
    XWindowChanges wc;

    if (!(dpy = XOpenDisplay(0)))
        return 1;

    root = DefaultRootWindow(dpy);

    XSelectInput(dpy, root, SubstructureRedirectMask);

    for (;;) {
        XNextEvent(dpy, &ev);

        switch (ev.type) {
        case MapRequest:
            XMapWindow(dpy, ev.xmaprequest.window);
            XSetInputFocus(dpy, ev.xmaprequest.window, RevertToParent, CurrentTime);
            XRaiseWindow(dpy, ev.xmaprequest.window);
            break;
        case ConfigureRequest:
            wc.x = ev.xconfigurerequest.x;
            wc.y = ev.xconfigurerequest.y;
            wc.width = ev.xconfigurerequest.width;
            wc.height = ev.xconfigurerequest.height;
            wc.border_width = ev.xconfigurerequest.border_width;
            wc.sibling = ev.xconfigurerequest.above;
            wc.stack_mode = ev.xconfigurerequest.detail;
            XConfigureWindow(dpy, ev.xconfigurerequest.window, ev.xconfigurerequest.value_mask, &wc);
            break;
        }
    }
}

Code adapted from tinywm and dwm.

ClannadBred commented 4 years ago

Yes, i am in the same situation...