rien / reStream

Stream your reMarkable screen over SSH.
MIT License
732 stars 56 forks source link

lz4 Error 44 #74

Closed aril-spetalen closed 2 years ago

aril-spetalen commented 2 years ago

Dear guys,

I've installed reStream on an ubuntu system, and run it with my new remarkable 2. My remarkable recently updated to version 2.9. All install steps were seemingly successful.

Running reStream, the output indicates ffplay is executed with a corrupt stream(?), seemingly caused by a decompression problem with lz4(?).

Here's the full output:

[SSH] true
[SSH] cat /sys/devices/soc0/machine
[SSH] [ -f /dev/shm/swtfb.01 ]
[SSH] [ ! -f ~/restream ] && [ ! -f /opt/bin/restream ]
[SSH] PATH="$PATH:/opt/bin/:." restream -h 1404 -w 1872 -b 1 -f :mem:
*** LZ4 command line interface 64-bits v1.9.2, by Yann Collet ***
ffplay version 4.2.4-1ubuntu0.1 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Error 44 : Unrecognized header : file cannot be decoded  0B f=0/0   
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, bitrate: 525657 kb/s
    Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1872x1404, 525657 kb/s, 25 tbr, 25 tbn, 25 tbc
^C  nan M-V:    nan fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0   

A little googling on lz4 and error 44 pointed me here: https://github.com/lz4/lz4/issues/584 , but I wouldn't hope I need to create my own lz4 to get along..

Any suggestions what could be the reason to my problem, or a way to resolve or debug?

Kind regards, Aril

rien commented 2 years ago

Hi Aril

From your log file, the *** LZ4 ... version string is not supposed to be displayed, maybe the lz4 binary on your system is doing something weird. Can you confirm that lz4 --help contains the -d 'decompression' option?

Also please check if you're running the latest version of the reStream.sh script in the host and the restream binary on the reMarkable and that there are no changes. If these versions are different, weird things can happen.

If you are running the latest version, can you try modifying the script to log the output to file like this:

diff --git a/reStream.sh b/reStream.sh
index 6285cd6..b2e95ca 100755
--- a/reStream.sh
+++ b/reStream.sh
@@ -235,6 +235,7 @@ fi

 # shellcheck disable=SC2086,SC2090
 $receive_cmd \
+    | tee output.log \
     | $decompress \
     | $host_passthrough \
     | (

And then see what the output.log file looks like after running restream? The file will be binary, but file should say it is an LZ4 stream:

$ file output.log 
output.log: LZ4 compressed data (v1.4+)

If not, can you check the contents of the file? I assume it could be some error message specifying what could be wrong.

I'm wondering what the issue might be here.

aril-spetalen commented 2 years ago

Thanks for this, @rien! I have a proper lz4, I suppose. The reason for the added version line is probably that, I myself added two options for debugging (replacing 'lz4 -d' with 'lz4 -d -v -l' just to see if I could get some knowledge on any possible compression problem). Sorry! I just removed that, to avoid confusion.

Patching the reStream script as you suggested, I got this output:

Usage: ./restream [-p] [-u] [-s <source>] [-o <output>] [-f <format>] [-t <title>]
Examples:
        ./restream                              # live view in landscape
        ./restream -p                           # live view in portrait
        ./restream -s 192.168.0.10              # connect to different IP
        ./restream -o remarkable.mp4            # record to a file
        ./restream -o udp://dest:1234 -f mpegts # record to a stream
  ./restream -w                           # write to a webcam (yuv420p + resize)
  ./restream -u                           # establish a unsecure but faster connection

Looking into the script, the given options are:

-h $height -w $width -b $bytes_per_pixel -f $fb_file

... so could the height and width params be unsupported? (Guess not. No video pops up if I try without it either. I just don't get an output then..)

aril-spetalen commented 2 years ago

Is there a mismatch with arguments here, @rien ? The output suggests to use -w for webcam. The script (reStream.sh) calls restream (on reMarkable) with -w $width.

rien commented 2 years ago

Aha, you need to have the restream binary (not the script reStream.sh) on your reMarkable. There are instructions described in the README here. The binary accepts other arguments than the script.

You can overwrite the restream file on your remarkable with the binary, reset the modifications in the reStream.sh file

It is indeed confusing that there are two different executables with the same name. I will try to make this more clear in a future version.

aril-spetalen commented 2 years ago

Ahh, how could I do that mistake! (All aware of the difference, but still getting it wrong.) Thanks for pointing it out! Ran this one (had got the wrong file, when doing this manually):

$ ssh root@10.11.99.1 'wget https://github.com/rien/reStream/releases/latest/download/restream.arm.static -O /home/root/restream && chmod +x /home/root/restream'

Screenshot from 2021-09-08 11-00-25

rien commented 2 years ago

Good to hear the issue is resolved, enjoy! :smile: