From a1b14bdf418327603da560fee7e1df9c5d384dfb Mon Sep 17 00:00:00 2001 From: Rien Maertens Date: Sun, 19 Apr 2020 15:53:14 +0200 Subject: [PATCH] Measure troughput with -t --- README.md | 1 + reStream.sh | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09f6c92..d2ce447 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ reMarkable screen sharing over SSH. - `-o --output`: path of the output where the video should be recorded, as understood by `ffmpeg`; if this is `-`, the video is displayed in a new window and not recorded anywhere (default: `-`) - `-f --format`: when recording to an output, this option is used to force the encoding format; if this is `-`, `ffmpeg`’s auto format detection based on the file extension is used (default: `-`). - `-w --webcam`: record to a video4linux2 web cam device. By default the first found web cam is taken, this can be overwritten with `-o`. The video is scaled to 1280x720 to ensure compatibility with MS Teams, Skype for business and other programs which need this specific format. +- `-t --throughput`: use `pv` to measure how much data throughput you have (good to experiment with parameters to speed up the pipeline) If you have problems, don't hesitate to [open an issue](https://github.com/rien/reStream/issues/new) or [send me an email](mailto:rien.maertens@posteo.be). diff --git a/reStream.sh b/reStream.sh index 2bc4a71..685389c 100755 --- a/reStream.sh +++ b/reStream.sh @@ -6,6 +6,7 @@ landscape=true # rotate 90 degrees to the right output_path=- # display output through ffplay format=- # automatic output format webcam=false # not to a webcam +measure_throughput=false # measure how fast data is being transferred # loop through arguments and process them while [ $# -gt 0 ]; do @@ -29,6 +30,10 @@ while [ $# -gt 0 ]; do shift shift ;; + -t | --throughput) + measure_throughput=true + shift + ;; -w | --webcam) webcam=true format="v4l2" @@ -100,13 +105,26 @@ fi if [ -z "$compress" ]; then echo "Your remarkable does not have lz4." fallback_to_gzip -elif ! lz4 -V; then +elif ! lz4 -V > /dev/null; then echo "Your host does not have lz4." fallback_to_gzip else decompress="lz4 -d" fi +# use pv to measure throughput if desired, else we just pipe through cat +if $measure_throughput; then + if ! pv --version > /dev/null; then + echo "You need to install pv to measure data throughput." + exit 1 + else + loglevel="error" # verbose ffmpeg output interferes with pv + host_passthrough="pv" + fi +else + host_passthrough="cat" +fi + # list of ffmpeg filters to apply video_filters="" @@ -164,6 +182,7 @@ set -e # stop if an error occurs # shellcheck disable=SC2086 ssh_cmd "$read_loop" \ | $decompress \ + | $host_passthrough \ | "$output_cmd" \ -vcodec rawvideo \ -loglevel "$loglevel" \