As crazy/stupid as it sounds, I did it.
Managed to show the local RTSP stream from a Tapo surveillance camera on a rooted / jailbroken Kindle Paperwhite, without servers, just ffmpeg
and eips
–
The idea
eips
is a custom e-ink support program for kindles
Find more info here
Fortunately on a Kindle (rooted) there is also a build of the ffmpeg
lib, which will come in very handy.
The idea of the script that is running on the Kindle (no servers! “serverless” in the real sense) is the following:
I want to use the RTSP stream of my Tapo camera and grab a snapshot (1 frame of the stream)
Since I don’t have ImageMagick installed (and can’t compile it from source) on my Kindle, I’ll need to do everything with one ffmpeg command.
eips
will come into play to render the image every few seconds.
This is going to be great-scale (alright, sorry for the pun)
–
The script
#/bin/sh
while true; do
ffmpeg -y -rtsp_transport tcp \
-i "rtsp://<username>:<password>@<tapocamip>:554/stream1" \
-f image2 \
-pix_fmt gray \
-vf "scale=1920:-1,transpose=1" \
-vframes 1 \
output.png
eips -cfg output.png
sleep 5
done
FFmpeg
To break down the ffmpeg
command:
-y
to overwrite theoutput.png
file at every run-rtsp_transport tcp
because I was getting dropped chunks during the transport with UDP on my spotty network-i "rtsp://..."
well that’s the source where I am getting the rstp stream duh-f image2
tells ffmpeg to store a sequence of individual image frames as separate files (in conjuction with-vframes 1
)-pix_fmt gray
because Kindles work best with 8-bit grayscale PNGs-vf "scale=1920:-1,transpose=1"
to scale the image maintaining the aspect ratio and rotate it 90deg clockwise, so it fills the whole screen of the Kindle
eips
The eips -cfg
does the following:
-c
clears the screen before updating it-f
perform a full screen update-g
to tell it it’s a PNG file
Prevent Kindle going to sleep
Borrowed from this repo
Prepend this to the script:
lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
stop powerd
More info about lipc-set-prop
or use the KUAL Helper extension to prevent the screensaver manually.
Proof of Kindle
Installation
You could spin this up in a cron, or through init.d
Or by using a generic cron that runs every minute an make a different script without the while
loop, e.g.
* * * * * /mnt/us/cam-once.sh
To do that, first make your filesystem writable
mntroot rw
Then edit the crontab
vi /etc/crontab/root