From edabacfb5555e8a840c820f42ed251d958770dcd Mon Sep 17 00:00:00 2001 From: f3fora <33097027+f3fora@users.noreply.github.com> Date: Sat, 30 Jan 2021 10:25:21 +0100 Subject: [PATCH] hflip: eventually restore the correct orientation of web cam --- README.md | 1 + reStream.sh | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8909a89..69879c1 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ $ ssh root@10.11.99.1 'chmod +x /home/root/restream' - `-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. See [Video4Linux Loopback](#video4linux-loopback) for installation instructions. +- `--hflip`: mirror the web cam video (`--webcam` has to be set). By default or as only choice, some programs, such as Zoom and Discord, mirror the camera. This flag restores the correct orientation. - `-m --measure`: use `pv` to measure how much data throughput you have (good to experiment with parameters to speed up the pipeline) - `-t --title`: set a custom window title for the video stream. The default title is "reStream". This option is disabled when using `-o --output` - `-u --unsecure-connection`: send framebuffer data over an unencrypted TCP-connection, resulting in more fps and less load on the reMarkable. See [Netcat](#netcat) for installation instructions. diff --git a/reStream.sh b/reStream.sh index 36f4ef6..c08d29f 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 +hflip=false # horizontal flip webcam measure_throughput=false # measure how fast data is being transferred window_title=reStream # stream window title is reStream video_filters="" # list of ffmpeg filters to apply @@ -58,6 +59,11 @@ while [ $# -gt 0 ]; do fi shift ;; + --hflip) + # do nothing if --webcam is not set + hflip=true + shift + ;; -t | --title) window_title="$2" shift @@ -68,15 +74,15 @@ while [ $# -gt 0 ]; do shift ;; -h | --help | *) - echo "Usage: $0 [-p] [-u] [-s ] [-o ] [-f ] [-t ]" + echo "Usage: $0 [-p] [-u] [-s <source>] [-o <output>] [-f <format>] [-t <title>] [-m] [-w] [--hflip]" echo "Examples:" echo " $0 # live view in landscape" echo " $0 -p # live view in portrait" echo " $0 -s 192.168.0.10 # connect to different IP" echo " $0 -o remarkable.mp4 # record to a file" echo " $0 -o udp://dest:1234 -f mpegts # record to a stream" - echo " $0 -w # write to a webcam (yuv420p + resize)" - echo " $0 -u # establish a unsecure but faster connection" + echo " $0 -w --hflip # write to a webcam (yuv420p + resize + mirror)" + echo " $0 -u # establish a unsecure but faster connection" exit 1 ;; esac @@ -174,6 +180,10 @@ if $webcam; then video_filters="$video_filters,format=pix_fmts=yuv420p" video_filters="$video_filters,scale=-1:720" video_filters="$video_filters,pad=1280:0:-1:0:#eeeeee" + + # Some applications, eg Zoom and Discord, mirror by default the webcam video + # Restore the correct orientation + $hflip && video_filters="$video_filters,hflip" fi # set each frame presentation time to the time it is received