Graceful fallback to gzip if zstd is not present
This commit is contained in:
parent
0cdbae1cb2
commit
7558b0935a
@ -6,11 +6,9 @@ Snappy reMarkable screen sharing over SSH.
|
||||
|
||||
On your **host** machine:
|
||||
- Any POSIX-shell (e.g. bash)
|
||||
- [zstd](http://www.zstd.net/)
|
||||
- ffmpeg (with ffplay)
|
||||
- ssh
|
||||
|
||||
On your **reMarkable**:
|
||||
- zstd (`opkg install zstd`)
|
||||
- netcat (`opkg install netcat`)
|
||||
- coreutils-head (`opkg install coreutils-head`)
|
||||
On your **reMarkable** it is recommended to install [zstd](https://zstd.net) (`opkg install zstd` if you have [entware](https://github.com/evidlo/remarkable_entware) installed.) to have a smoother experience (sub-second latency). However, if you don't have it installed `reStream` will fall back to `gzip` which is installed by default.
|
||||
|
||||
|
||||
|
36
reStream.sh
36
reStream.sh
@ -1,40 +1,44 @@
|
||||
#!/bin/sh
|
||||
set -eo pipefail
|
||||
|
||||
ssh_host="mohowzeg.usb"
|
||||
landscape=true
|
||||
|
||||
bin_head="/opt/bin/head"
|
||||
bin_zstd="/opt/bin/zstd"
|
||||
bin_ncat="/opt/bin/netcat"
|
||||
width=1408
|
||||
height=1872
|
||||
bytes_per_pixel=2
|
||||
loop_wait="true"
|
||||
loglevel="info"
|
||||
|
||||
|
||||
if ! ssh "$ssh_host" true; then
|
||||
echo "$ssh_host unreachable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for prog in $bin_head $bin_zstd $bin_ncat; do
|
||||
if ! ssh "$ssh_host" "[ -f $prog ]"; then
|
||||
echo "Program $prog is not present on $ssh_host."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
# Gracefully degrade to gzip if zstd is not present
|
||||
if ssh "$ssh_host" "[ -f /opt/bin/zstd ]"; then
|
||||
compress="/opt/bin/zstd"
|
||||
decompress="zstd -d"
|
||||
else
|
||||
compress="gzip"
|
||||
decompress="gzip -d"
|
||||
fi
|
||||
|
||||
|
||||
window_bytes="$(($width*$height*$bytes_per_pixel))"
|
||||
landscape_param="$($landscape && echo '-vf transpose=1')"
|
||||
read_loop="while $bin_head -c $window_bytes /dev/fb0; do sleep .03; done | $bin_zstd"
|
||||
orientation_param="$($landscape && echo '-vf transpose=1')"
|
||||
head_fb0="dd if=/dev/fb0 count=1 bs=$window_bytes 2>/dev/null"
|
||||
read_loop="while $head_fb0; do $loop_wait; done | $compress"
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
ssh "$ssh_host" "$read_loop" \
|
||||
| zstd -d \
|
||||
| pv - \
|
||||
| $decompress \
|
||||
| ffplay -vcodec rawvideo \
|
||||
-loglevel error \
|
||||
-loglevel "$loglevel" \
|
||||
-f rawvideo \
|
||||
-pixel_format gray16le \
|
||||
-video_size "$width,$height" \
|
||||
$landscape_param \
|
||||
-i -
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user