KaiScr is a project released by Farooq Karimi Zadeh on NotABug.
KaiScr is is a project with two scripts: kailive.py
and kaiscr.py
. The first one is for screen mirroring and the other for taking screenshots, one or more, from your KaiOS or FFOS device.
This Peertube video shows usage of the scripts. Same video on Youtube
Plug the device while in debug mode with a USB cable.
Execute this command adb forward tcp:6000 localfilesystem:/data/local/debugger-socket
Fetch the repository either by downloading one of the archives or by cloning it using git clone https://notabug.org/farooqkz/kaiscr
Now proceed to one of the next sections depending on your need.
kaiscr.py
Run the script with -h
to see how you should use it:
python3 kaiscr.py -h
Then it will print the usage to standard output:
usage: kaiscr.py [-h] [--host host] [--port port] [--prefix prefix]
[--count count]
Take screenshot(s) from a KaiOS/FFOS device
optional arguments:
-h, --help show this help message and exit
--host host The host to connect to
--port port The port to connect to
--prefix prefix The prefix for naming files
--count count How many times should I take screenshot? 0 does
nothing and negative values take screenshot forever
host
and port
default to localhost:6000
and it takes just one screenshot if you don't specify count
.
Assuming you are on Linux and you have ImageMagick installed, use these commands to take 100 screenshots and then convert them to a GIF:
python3 kaiscr.py --count 100 --prefix shot
# ... after the script finished its task ...
convert -delay 5 -loop 0 shot*.png shots.gif
Then you'll have shots.gif
.
convert them to a .mp4 with memcoder
mencoder mf://*.png -mf w=800:h=600:fps=20:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.mp4
kailive.py
You only need to run the script after you have forwarded the debugger-socket:
python3 kailive.py
Press q anytime to exit.
This part has been written directly by Farooq Karimi Zadeh
The System app uses a code like this to take screenshot of the screen:
let window = Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType);
let canvas = document.createElement("canvas");
let width = window.innerWidth;
let height = window.innerHeight;
let pixelRatio = window.devicePixelRatio;
canvas.setAttribute("width", Math.round(width * pixelRatio));
canvas.setAttribute("height", Math.round(height * pixelRatio));
let context = canvas.getContext("2d");
let flags = context.DRAWWINDOW_DRAW_CARET |
context.DRAWWINDOW_DRAW_VIEW |
context.DRAWWINDOW_USE_WIDGET_LAYERS;
context.scale(pixelRatio, pixelRatio);
context.drawWindow(window, 0, 0, width, height, 'black', flags);
let dataURL = canvas.toDataURL();
// ...
However adding these options to getContext
and replacing toDataURL
with a setInterval
with context.getImageData
inside slows down the device and doesn't bring high FPS, not even 20.
{
desynchronized: true,
willReadFrequently: true
}