Can't get firefox to render the right size in a headless xvfb instance
Solution 1
Here is a solution, not pretty but works. Uses xdotool
to set size after Firefox
is running.
First:
xdotool search --onlyvisible firefox
This will display a single window ID, windowid
. Then:
xdotool windowmove windowid 0 0
xdotool windowsize windowid 1280 720
You must first do the windowmove
and follow it by the windowsize
.
In some cases once I did this, the size and position were correct forever more, in other cases had to run again each time I ran Firefox
.
Solution 2
Assume the border is there and compensate accordingly in your capture. If you need 1024x768, then set the screen size to 1034x778 and capture 1024x768
Xvfb :1 -screen 0 1034x778x24 > /dev/null &
ffmpeg -t 1 -s 1024x768 -f x11grab -i :1.0+10,10 -f mjpeg screenshot.png
Related videos on Youtube
Ryan Detzel
I love startups and bleeding edge tech. Lets chat if you can help me with either of those. :-)
Updated on September 18, 2022Comments
-
Ryan Detzel over 1 year
I can start the xvfb instance just fine
Xvfb :1 -screen 0 800x600x24
I can then launch firefox and have it load correctly but the window is always smaller than the resolution I set during the xvfb command.
firefox http://www.ebay.com --display=:1
You can see the black bar, that's the full resolution. It appears it's sizing to what the page wants but it will never fill it out completely.
-
ish almost 12 yearsWhat is your goal?
-
Ryan Detzel almost 12 yearsI want to get an accurate screenshot at different resolutions. Since this is not the exact resolution it messes up my tests.
-