You are not logged in.

#1 2018-12-10 12:04:56

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

ssh-rdp: zero latency remote desktop suitable for gaming.

EDIT:
superseeded by: https://github.com/kokoko3k/ssh-rdp

Hi all,
i'd like to share with you my work of the last week,
Basically, it is a bash script that allows you to connect to a remote desktop, but has some nice features:

* Everything is done through ssh
* Good video quality thanks to h264 codec
* Latency is zero on localhost, it entirely depends on the network and cpu power.
* Hardware encoding (couldn't test amd or intel)
* Sound support
* Suitable for remote gaming (depends on your network)

From my tests, i've found that to achieve the lowest latencies, the best tool to use on the client is ffplay with some nice flags; when using the script to connect to the local desktop, (dual head setup).
Also, recent mpv versions with provided flags offers even better latencies.

So ffmpeg on the remote machine grabs the screen, encodes it and sends everything through an ssh pipe.
The same is done for audio, with the help of pulseaudio on the remote side. I've found that sending audio and video on two separate streams, helps with latency.
Keyboard and mouse forwarding is handled by netevent; even here data passes through ssh via port forwarding.

Software needed:
* Local and Remote: ffmpeg,openssh,netevent-git
* Local:  inotify-tools, wmctrl, optional: mpv + taskset from util-linux to get even lower latency but with more cpu use.
* Remote: xdpyinfo,pulseaudio

It is also mandatory to:
* set-up an ssh key based authentication
* have local and remote users in the input group

How to make it work:
* setup an ssh based authentication with the remote host
* Open the script and edit it to suit your needs
* Start the script from a terminal
* Select which devices you want to share
* Configure input hotkeys as asked, one will be used to forward/unforward devices, the other to make the window fullscreen/windowed.
* start ssh-rdp.sh inputconfig to reconfigure inputs.

Drawbacks:
* Due to some pulseaudio shortcomings, sometimes the audio get desyncronized, it will recover by itself by speeding up, and you can hear high-pitched sound.
* Just clicking in the remote window does not pass the control to it, because that is the ffplay window; so hitting the hotkey is mandatory.
* For remote gaming, turning on cpu encoder may give better results than gpu encoder, if the gpu is already at its limit.

I'm open to suggestions to make this software better!
Notably, it lacks a way to use amd and intel gpu encoders.
If anybody could write and post a VIDEO_ENC string, it would be really nice.


#!/bin/bash

#ToDo: Remote window title is wrong
#	multiplexing
#	custom cipher

#Requirements:
    #Local+Remote: ffmpeg,?????????????????,openssh,netevent-git
    #Local: inotify-tools, wmctrl, optional: mpv + taskset from util-linux to get even lower latency but with more cpu use.
    #Remote: xdpyinfo,pulseaudio
    #read/write access to input devices on local and remote system (input group) (sudo gpasswd --add username input)

#Restrictions: only one keyboard supported.

#Remote host (you can pass the following via command line in the format:  john@server:22:0.0)
    RHOST="" # Remote ip or hostname
    RPORT="22"             # Remote ssh port to connect to
    RUSER=""             # The user on the remote side running the real X server
    RDISPLAY="0.0"          # The remote display (ex: 0.0)
    EVDFILE="$HOME/.config/ssh-rdp.input.evd.config"  #Holds the name of the forwarded evdev device 
    KBDFILE="$HOME/.config/ssh-rdp.input.kbd.config"  #Holds the name of the forwarded keyboard evdev device
    HKFILE="$HOME/.config/ssh-rdp.input.hk.config"    #where the keypress codes to switch fullscreen and forward reside

    #GRAB_HOTKEY="" # Grab/Ungrab devices 70=scroll_lock (commented because it is read from a file)
    #FULLSCREENSWITCH_HOTKEY="" # Switch fullscreen (commented because it is read from a file)
    
#Encoding:
    AUDIO_CAPTURE_SOURCE="guess" # "pulseaudio name like alsa_output.pci-0000_00_1b.0.analog-stereo.monitor" or "guess"
    FPS=30         # frames per second of the stream
    RES="auto"     # "ex: RES="1280x1024" or RES="auto". 
                   # If wrong, video grab will not work.
    OFFSET="+0,0"      # ex: OFFSET="" or OFFSET="+10,+40".
                   # If wrong, video grab will not work.

    AUDIO_BITRATE=128 #kbps
    AUDIO_ENC="-acodec libopus -vbr off -application lowdelay"
    AUDIO_DELAY_COMPENSATION="2500" #The higher the value, the lower the audio delay.
                                    #Setting this too high will likely produce crackling sound.
                                    #Try in range 0-9000
    VIDEO_BITRATE_MAX="5000"  #kbps (or AUTO)

    #cpu encoder
    VIDEO_ENC="-threads 1 -vcodec libx264 -thread_type slice -slices 1 -level 32 -preset ultrafast -tune zerolatency -intra-refresh 1 -x264opts vbv-bufsize=1:slice-max-size=1500:keyint=$FPS:sliced_threads=1"
    #nvidia gpu encoder
    #VIDEO_ENC="-threads 1 -c:v h264_nvenc -preset llhq -delay 0 -zerolatency 1"
    #amd gpu encoder
    #VIDEO_ENC="-threads 1 -vaapi_device /dev/dri/renderD128 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi"
    #intel gpu encoder
    #VIDEO_ENC="???"

    #Remote window title
    WTITLE="$RUSER@$RHOST""$RDISPLAY"
    
# Decoding
    #ffplay, low latency, no hardware decoding
    VIDEOPLAYER="ffplay - -nostats -window_title "$WTITLE" -probesize 32 -flags low_delay -framedrop  -fflags nobuffer+fastseek+flush_packets -analyzeduration 0 -sync ext"
    #mpv, less latency, possibly hardware decoding, hammers the cpu.
    #VIDEOPLAYER="taskset -c 0 mpv - --input-cursor=no --input-vo-keyboard=no --input-default-bindings=no --hwdec=auto --title="$WTITLE" --untimed --no-cache --profile=low-latency --opengl-glfinish=yes --opengl-swapinterval=0"

# Misc
    SSH_CIPHER="" #Optionally, force an ssh cipher to be used
    #SSH_CIPHER="aes256-gcm@openssh.com"


# ### User config ends here ### #

ICFILE_RUNTIME=~/.config/ssh-rdp.input.out.config

generate_ICFILE_from_names() {
    #Also, exits from the script if no keyboard is found
    I_IFS="$IFS"
	IFS=$'\n' ;
    ICFILE_REJ=~/.config/ssh-rdp.input.rej.txt

    rm $ICFILE_RUNTIME $ICFILE_REJ &>/dev/null
    ERROR="0"
    echo [..] Checking input devices...
	for device_name in $(<$EVDFILE) ; do
		evdev_devices=$(events_from_name "$device_name")
		if [ "$evdev_devices" = "" ] ; then
			echo "[!!] Device unavailable : $device_name"
				else
			echo "[OK] Device ready       : $device_name"
			for evdevice in $evdev_devices ; do
				echo "     add event device for $device_name: $evdevice"
				echo -n $evdevice" " >> "$ICFILE_RUNTIME"
			done
		fi
    done
    IFS="$I_IFS"
    echo [..] Reading hotkey file $HKFILE
    read GRAB_HOTKEY FULLSCREENSWITCH_HOTKEY <<< $(<$HKFILE)
    echo [OK] GRAB_HOTKEY=$GRAB_HOTKEY
    echo [OK] FULLSCREENSWITCH_HOTKEY=$FULLSCREENSWITCH_HOTKEY

}

name_from_event(){
	#es: name_from_event event3 
	#Logitech G203 Prodigy Gaming Mouse
	grep 'Name=\|Handlers' /proc/bus/input/devices|grep -B1 "$1"|head -n 1|cut -d \" -f 2
}


events_from_name(){
	#es: vents_from_name Logitech G203 Prodigy Gaming Mouse
	#event13
	#event2
	grep 'Name=\|Handlers' /proc/bus/input/devices|grep -A1 "$1"|cut -d "=" -f 2 |grep -o '[^ ]*event[^ ]*'
}

create_input_files() {
    tmpfile=/tmp/$$devices$$.txt
    sleep 0.1
    timeout=10 #seconds to probe for input devices
    cd /dev/input/

    #Ask user to generate input to auto select input devices to forward
    echo Please, generate input on devices you want to forward, keyboard is mandatory!
    rm $tmpfile &>/dev/null
    for d in event* ; do 
        sh -c "timeout 10 grep . $d -m 1 -c -H |cut -d ":" -f 1 |tee -a $tmpfile &" 
    done 
    echo Waiting 10 seconds for user input...
    sleep $timeout
    list=""
	#Make a list of device names
	rm $EVDFILE &>/dev/null
    for evdevice in $(<$tmpfile) ; do 
		name=$(name_from_event $evdevice|tr " " ".")
		list="$list $name $evdevice off "
		echo $(name_from_event $evdevice)  >> $EVDFILE
    done
    #ask user to select the keyboard device
	echo "Press a key on the keyboard which will be forwarded."
    KBDDEV=$(inotifywait event* -q | cut -d " " -f 1)
    echo "Got $(name_from_event $KBDDEV)"
    name_from_event $KBDDEV > $KBDFILE

	# create_hk_file
	# uses netevent to generate a file containing the key codes
	# to switch fullscreen and forward devices
		cd /dev/input
		rm $HKFILE &>/dev/null
		sleep 1
		echo ; echo Press the key to forward/unforward input devices
		GRAB_HOTKEY=$(netevent show $KBDDEV 3 -g | grep KEY |cut -d ":" -f 2) ; echo got:$GRAB_HOTKEY
		sleep 0.5
		echo ; echo Press the key to switch fullscreen state
		FULLSCREENSWITCH_HOTKEY=$(netevent show $KBDDEV 3 -g | grep KEY |cut -d ":" -f 2) ; echo got:$FULLSCREENSWITCH_HOTKEY
		echo $GRAB_HOTKEY $FULLSCREENSWITCH_HOTKEY > $HKFILE

		read GRAB_HOTKEY FULLSCREENSWITCH_HOTKEY <<< $(<$HKFILE)
		echo
		echo GRAB_HOTKEY=$GRAB_HOTKEY
		echo FULLSCREENSWITCH_HOTKEY=$FULLSCREENSWITCH_HOTKEY
}

list_descendants() {
    local children=$(ps -o pid= --ppid "$1")
    for pid in $children ; do
        list_descendants "$pid"
    done
    echo "$children"
}   

#Clean function
finish() {
    echo ; echo TRAP: finish.
    kill $(list_descendants $$) &>/dev/null
    rm $NESCRIPT &>/dev/null
}
trap finish INT TERM EXIT

#Test and report net download speed
benchmark_net() {
    $SSH_EXEC sh -c '"timeout 1 dd if=/dev/zero  bs=1b "' | cat - > /tmp/zero
    #KBPS=$(( $(wc -c < /tmp/zero) *8/1000   ))  # 100%
    #KBPS=$(( $(wc -c < /tmp/zero) *8/1200   ))  # 80%
    KBPS=$(( $(wc -c < /tmp/zero) *8/2000   ))  # 50%
    #KBPS=$(( $(wc -c < /tmp/zero) *8/3000   ))  # 33%
    #KBPS=$(( $(wc -c < /tmp/zero) *8/10000   )) # 10%
    echo $KBPS
}

FS="F"
setup_input_loop() {    
    #Parse remote hotkeys and perform local actions (eg: Fullscreen switching)
    echo "[..] Setting up input loop and forwarding devices"
    #Prepare netevent script
    i=1
    touch $NESCRIPT
    KBDNAME=$(<$KBDFILE)
    for DEVICE in $(<$ICFILE_RUNTIME) ; do
        echo "     forward input from device $DEVICE..."
        DEVNAME=$(name_from_event "$DEVICE")
        #if [[ $DEVICE == *"event-kbd"* ]] ; then
        if  [ "$DEVNAME" = "$KBDNAME" ] ; then 
            echo "device add mykbd$i /dev/input/$DEVICE"  >>$NESCRIPT
			echo "hotkey add mykbd$i key:$GRAB_HOTKEY:1 grab toggle" >>$NESCRIPT
			echo "hotkey add mykbd$i key:$GRAB_HOTKEY:0 nop" >>$NESCRIPT
			echo "hotkey add mykbd$i key:$FULLSCREENSWITCH_HOTKEY:1 exec \"/usr/bin/echo FULLSCREENSWITCH_HOTKEY\"" >>$NESCRIPT
			echo "hotkey add mykbd$i key:$FULLSCREENSWITCH_HOTKEY:0 nop" >>$NESCRIPT
                else
            echo "device add dev$i /dev/input/$DEVICE"  >>$NESCRIPT
        fi
        let i=i+1
    done
    echo "output add myremote exec:$SSH_EXEC netevent create" >>$NESCRIPT
    echo "use myremote" >>$NESCRIPT

    echo "[..] Starting netevent daemon"
    netevent daemon -s $NESCRIPT netevent-command.sock | while read -r hotkey; do
        echo "read hotkey: " $hotkey
        if [ "$hotkey" = "FULLSCREENSWITCH_HOTKEY" ] ; then
            if [ "$FS" = "F" ] ; then
                wmctrl -b add,fullscreen -r "$WTITLE"
                wmctrl -b add,above -r "$WTITLE"
                FS="T"
                    else
                wmctrl -b remove,fullscreen -r "$WTITLE"
                wmctrl -b remove,above -r "$WTITLE"
                FS="F"
            fi
        fi
    done
}

# ### MAIN ### ### MAIN ### ### MAIN ### ### MAIN ###

if [ "$1 " = "inputconfig " ] ; then
    create_input_files
    exit
fi

if [ ! $1 = "" ] ; then
    #read user and host and override defaults if specified by command line
    read RUSER RHOST RPORT_R RDISPLAY_R RES_R OFFSET_R FPS_R AUDIO_BITRATE_R VIDEO_BITRATE_MAX_R <<< $(echo "$1" | awk -F [@:] '{print $1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9}')
    [ "$RPORT_R" != "" ]    && RPORT=$RPORT_R
    [ "$RDISPLAY_R" != "" ] && RDISPLAY=$RDISPLAY_R
    [ "$RES_R" != "" ]      && RES=$RES_R
    [ "$OFFSET_R" != "" ]   && OFFSET=$OFFSET_R
    [ "$FPS_R" != "" ]   && FPS=$FPS_R
    [ "$AUDIO_BITRATE_R" != "" ]   && AUDIO_BITRATE=$AUDIO_BITRATE_R
    [ "$VIDEO_BITRATE_MAX_R" != "" ]   && VIDEO_BITRATE_MAX=$VIDEO_BITRATE_MAX_R
fi

#Sanity check    
    me=$(basename "$0")
    if [ -z $RUSER ] || [ -z $RHOST ] || [ "$1" = "-h" ] ; then
        echo Please edit "$me" to suid your needs and/or use the following options:
        echo Format: "$me" "user@host:ssh-port:DISPLAY:size:offset:fps:abitrate:vbitrate"
        echo ""
        echo "Example 1: john connecting to jserver, all defaults accepted"
        echo "    Ex: "$me" john@jserver"
        echo 
        echo "Example 2:"
        echo "    john connecting to jserver on ssh port 322, streaming the display 0.0"
        echo "    remote setup is dual head and john selects the right monitor."
        echo "    Stream will be 128kbps for audio and 10000kbps for video:"
        echo "    Ex: $me john@jserver:322:0.0:1920x1080:+1920,0:60:128:10000"
        echo ""
        echo "    Use: $me inputconfig (to create or change the input config file)"
        echo
        echo "user and host are mandatory."
        echo "default ssh-port: $RPORT"
        echo "default DISPLAY : $RDISPLAY"
        echo "default size    : $RES"
        echo "default offset  : $OFFSET"
        echo "default fps     : $FPS"
        echo "default abitrate: $AUDIO_BITRATE kbps"
        echo "default vbitrate: $VIDEO_BITRATE_MAX kbps"
        exit
    fi
    RDISPLAY=":$RDISPLAY"

    if [ ! -f "$EVDFILE" ] ; then
        echo "[EE] Input configuration file "$EVDFILE" not found!"
        echo "Please, Select which devices to share."
        sleep 2
        create_input_files
    fi

echo
echo "[..] Trying to connect to $RUSER@$RHOST:$RPORT"
echo "     and stream display $DISPLAY"
echo "     with size $RES and offset: $OFFSET"
echo

generate_ICFILE_from_names

#netevent script file
    NESCRIPT=/tmp/nescript$$

SSH_CONTROL_PATH=$HOME/.config/ssh-rdp$$

#Shortcut to start remote commands:
    [ ! "$SSH_CIPHER" = "" ] && SSH_CIPHER=" -c $SSH_CIPHER"
    SSH_EXEC="ssh $SSH_CIPHER -o ControlMaster=auto -o ControlPath=$SSH_CONTROL_PATH $RUSER@$RHOST -p $RPORT"


#Setup SSH Multiplexing
    ssh -fN -o ControlMaster=auto -o ControlPath=$SSH_CONTROL_PATH -o ControlPersist=300 $RUSER@$RHOST -p $RPORT

#We need to kill some processes on exit, do it by name.
    FFMPEGEXE=/tmp/ffmpeg$$
    $SSH_EXEC "ln -s \$(which ffmpeg) $FFMPEGEXE"
    FFPLAYEXE=/tmp/ffplay$$
    $SSH_EXEC "ln -s \$(which ffplay) $FFPLAYEXE"

setup_input_loop &

PID1=$!

#Measure network download speed?
if [ "$VIDEO_BITRATE_MAX" = "AUTO" ] ; then
    echo "[..] Measuring network throughput"
    VIDEO_BITRATE_MAX=$(benchmark_net)
    if [ $VIDEO_BITRATE_MAX -gt 294987 ] ; then
        echo $VIDEO_BITRATE_MAX too high!
        VIDEO_BITRATE_MAX=100000 
    fi
    echo Using "[OK] $VIDEO_BITRATE_MAX"Kbps
    echo
fi

#Guess audio capture device?
    if [ "$AUDIO_CAPTURE_SOURCE" = "guess" ] ; then
		echo "[..] Guessing audio capture device"
        AUDIO_CAPTURE_SOURCE=$($SSH_EXEC echo '$(pacmd list | grep "<.*monitor>" |awk -F "[<>]" "{print \$2}" | tail -n 1)')
        # or: AUDIO_CAPTURE_SOURCE=$($SSH_EXEC echo '$(pactl list sources short|grep monitor|awk "{print \$2}" | head -n 1)
        echo "[OK] Guessed audio capture source:" $AUDIO_CAPTURE_SOURCE
		echo
    fi
    
#Auto video grab size?
    if [ "$RES" = "auto" ] || [ "$RES" = "" ] ; then
		echo "[..] Guessing remote resolution"
        RES=$($SSH_EXEC "export DISPLAY=$RDISPLAY ; xdpyinfo | awk '/dimensions:/ { print \$2; exit }'")
        echo "[OK] Auto grab resolution: $RES"
        echo
    fi

#Grab Audio
	echo [..] Start audio streaming...
    $SSH_EXEC sh -c "\
        export DISPLAY=$RDISPLAY ;\
        $FFMPEGEXE -v quiet -nostdin -y -f pulse -ac 2 -i "$AUDIO_CAPTURE_SOURCE"  -b:a "$AUDIO_BITRATE"k "$AUDIO_ENC" -f nut -\
    " | \
    ffplay - -nostats -loglevel warning -flags low_delay -nodisp -probesize 32 -fflags nobuffer+fastseek+flush_packets -analyzeduration 0 -sync ext -af aresample=async=1:min_comp=0.1:first_pts=$AUDIO_DELAY_COMPENSATION &
    PID4=$!

	echo [..] Start video streaming...
    $SSH_EXEC sh -c "\
        export DISPLAY=$RDISPLAY ;\
        $FFMPEGEXE -nostdin -loglevel warning -y -f x11grab -r $FPS -framerate $FPS -video_size $RES -i "$RDISPLAY""$OFFSET"  -b:v "$VIDEO_BITRATE_MAX"k  -maxrate "$VIDEO_BITRATE_MAX"k \
        "$VIDEO_ENC" -f_strict experimental -syncpoints none -f nut -\
    " | $VIDEOPLAYER

Note:
VIDEO_BITRATE_MAX is set to 10000 (about 8Mbps), but you can choose "AUTO" instead.
This will cause the script to estimate the network throughput, and by default it will use 50% of it.
(search for the lines starting with  "KBPS=$(( $(wc -c < /tmp/zero) " and uncomment/comment according to your needs)


...actually i'm having success in remotely playing:
- "The turing test" via steamplay
- nvidia gpu encoder
- stream resolution is 1280x720@30fps
- cpu on both sides is Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
- gpu on remote side is an nvidia GTX 750ti
- remote fps is about 60fps
- maximum bandwidth used: 10Mbps

Last edited by kokoko3k (2020-04-11 12:48:50)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#2 2019-01-02 15:12:50

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Just edited and partially rewrote the script, since i discovered the great netevent and made an aur package too.
With netevent i removed synergy,xbindkeys and xdotool dependancies, so the script is much simpler now.
As a bonus, you can now share your local gamepad too!
Note that the local user and the remote one have to be in the input group (a logout may needed after modifying the group membership)

Last edited by kokoko3k (2019-01-02 15:14:03)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#3 2020-03-31 12:42:34

ulno
Member
Registered: 2020-03-31
Posts: 1

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Sorry, for reviving this old thread.

@kokoko3k: any interest in turning this script into a small project (and making it available on AUR) and adding some features to it?

I was thinking to add a license, support more gpus, resolutions, using simple tcp or udp vs. tunneled over ssh, showing other successful setups with tutorial, maybe even thinking about VR streaming to the Oculus Quest.

Offline

#4 2020-04-01 09:06:42

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

ulno wrote:

Sorry, for reviving this old thread.

@kokoko3k: any interest in turning this script into a small project (and making it available on AUR) and adding some features to it?

I was thinking to add a license, support more gpus, resolutions, using simple tcp or udp vs. tunneled over ssh, showing other successful setups with tutorial, maybe even thinking about VR streaming to the Oculus Quest.

You're welcome, i've updated the script with minor tweaks i made during this time.

* I don't think i want to add a license to it, do whatever you want.
* support more gpu: i already asked if someone wants to add new encoding lines, you're welcome to provide some.
* using simple tcp or udp vs. tunneled over ssh: that requires radical changes and added complexity i'd like to avoid, modern processors can encrpyt and decrypt very fast nowdays.
* resolutions: did you even read the script?
* VR streaming: if you own one, please go ahead and test, or maybe buy me one and i'll do all the work, i promise! smile


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#5 2020-04-07 13:49:15

marc1n
Member
Registered: 2015-09-24
Posts: 3

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

kokoko3k wrote:

* support more gpu: i already asked if someone wants to add new encoding lines, you're welcome to provide some.
* using simple tcp or udp vs. tunneled over ssh: that requires radical changes and added complexity i'd like to avoid, modern processors can encrpyt and decrypt very fast nowdays.

For AMD line is:
VIDEO_ENC="-threads 1 -vaapi_device /dev/dri/renderD128 -vf 'hwupload,scale_vaapi=format=nv12' -c:v h264_vaapi"

Maybe instead tcp/udp tunnels it would be better to use hardware encryption? It should decrease latency and cpu usage by using AES-NI extensions. Most modern CPUs support it.

SSH_EXEC="ssh -c aes256-gcm@openssh.com $RUSER@$RHOST -p $RPORT"

It could be useful to set up ssh multiplexing, so it wouldn't be needed to set up passwordless auth.
https://en.wikibooks.org/wiki/OpenSSH/C … ltiplexing


Also, great work, i was looking for something like this for months but didn't even think about doing stuff that way.

Offline

#6 2020-04-07 14:13:38

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Ohh, nice additions, thanks, i'll add the amd encoding line (is it giving you low latencies?) along with some other work i made on the input subsystem to better support a wider range of input devices.
notably, now inotify-tools package is needed and probably you'll need to start it again with inputconfig parameter.
Maybe it is better to make the cipher configurable with an env variable.
Going to study about ssh multiplexing, if it does not add compexity and latency, seems a win-win.

Last edited by kokoko3k (2020-04-07 14:22:30)


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#7 2020-04-08 13:38:28

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Ok, implemented multiplexing and the ability to optionally forcing ciphers.
Also, a repo:
https://github.com/kokoko3k/ssh-rdp/


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#8 2020-04-08 13:46:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

kokoko3k wrote:

* I don't think i want to add a license to it, do whatever you want.

This is completely self contradictory.  Without a license, no one is allowed to do *anyting* with the script.  Even saving it on their machine and/or using it as is would be illegal.  I license provides rights to use, copy, modify, distribute, etc.

If you want people to "do whatever they want", there are licenses that say just that.  But without a license, no one can do anything (legally).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2020-04-08 13:52:34

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Oh, i didn't know that, nor i think it should be that way.
Thanks for let me know, i'v added a license on github.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#10 2020-04-09 21:00:14

marc1n
Member
Registered: 2015-09-24
Posts: 3

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

kokoko3k wrote:

Ohh, nice additions, thanks, i'll add the amd encoding line (is it giving you low latencies?) along with some other work i made on the input subsystem to better support a wider range of input devices.
notably, now inotify-tools package is needed and probably you'll need to start it again with inputconfig parameter.
Maybe it is better to make the cipher configurable with an env variable.
Going to study about ssh multiplexing, if it does not add compexity and latency, seems a win-win.


Thanks for your work, it seems that for me Your solution offers better quality than eg. Steam Remote Play

I'm testing it on old AMD APU, and i'm able to even view FHD movies remotely wink
On more modern GPU - RX580 i didn't notice significant latency in games with the line above.

I also managed to test very fast version, that relies on internal GPU capture in addition to encode, so uncompressed video data isn't moved outside GPU, and that means a little less latency and a lot less CPU usage.

VIDEO_ENC="-threads 1 -device /dev/dri/card0 -vf 'hwmap=derive_device=vaapi,scale_vaapi=w=1920:h=1080:format=nv12' -c:v h264_vaapi -qp 24"
and:
-f -f kmsgrab
instead of:
-f x11grab
But it has downsides:
- you need to set up software cursor in video driver as with typical setup it wouldn't be visible.
- it managed to crash my Athlon 5350 internal GPU few times. It works with RX580 but i can't guarantee that it will be stable.
- ffmpeg needs to be run as root

Offline

#11 2020-04-09 21:10:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

GPL3 is a fine license - but it's quite far from your initial intent of letting anyone do whatever they want.  It may be the most restrictive FOSS license there is.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#12 2020-04-11 09:47:46

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,393

Re: ssh-rdp: zero latency remote desktop suitable for gaming.

Trilby wrote:

GPL3 is a fine license - but it's quite far from your initial intent of letting anyone do whatever they want.  It may be the most restrictive FOSS license there is.

Yes, i never thought deeply about licenses till now, being forced to choose one to let others even use a script made me think about it and i just changed my mind.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

Board footer

Powered by FluxBB