Giter Site home page Giter Site logo

thesauri / jsmpeg-vnc-linux Goto Github PK

View Code? Open in Web Editor NEW
33.0 9.0 16.0 24.44 MB

Linux port of jsmpeg-vnc: a low latency, high framerate screen sharing server for Linux and client for browsers

C 23.72% HTML 1.51% JavaScript 73.46% CMake 0.43% Dockerfile 0.89%

jsmpeg-vnc-linux's Introduction

jsmpeg-vnc-linux

A semi-complete Linux port of jsmpeg-vnc.

Compiling on Ubuntu 20.04

Install the following packages:

  • build-essential
  • libx11-dev
  • libx11-dev
  • libavutil-dev
  • libavcodec-dev
  • libswscale-dev
  • libxtst-dev
  • libssl-dev
  • pkg-config
  • zlib1g-dev

In addition to this, compile and install libwebsockets 4.1.

Then, run the following commands in the root directory:

cmake .
make

See the Dockerfile for an example on how to install the dependencies, compile libwebsockets, and compile jsmpeg-vnc-linux (it won't run out-of-the-box in Docker though, as there is nothing to stream).

Running

jsmpeg-vnc [options] <window name>

Options:
  -b bitrate in kilobit/s (default: estimated by output size)
  -s output size as WxH. E.g: -s 640x480 (default: same as window size)
  -f target framerate (default: 60)
  -p port (default: 8080)
  -c crop area in the captured window as X,Y,W,H. E.g.: -c 200,300,640,480
  -i enable/disable remote input. E.g. -i 0 (default: 1)

Use "desktop" as the window name to capture the whole Desktop. Use "cursor"
to capture the window at the current cursor position.

Example:
jsmpeg-vnc -b 2000 -s 640x480 -f 30 -p 9006 "Quake 3: Arena"

To enable mouse lock in the browser (useful for games that require relative
mouse movements, not absolute ones), append "?mouselock" at the target URL
i.e: http://<server-ip>:8080/?mouselock

(Copied from the parent project)

About

For a project I was working on I needed a way to stream desktop applications to the web browser. I tried creating a video stream using ffmpeg, but I quickly discovered that support of live video streaming was rather poor using only <video> tags. For interaction with desktop applications, the latency was too high (after a long battle to get it working at all). I then discovered the project jsmpeg-vnc which suited my needs very well. By creating a video stream, sending it over a WebSocket, and rendering the video onto a canvas element using JavaScript control was given over the screen capturing and rendering. That way, the latency could be minimized and the framerate kept high.

Unfortunately, the jsmpeg-vnc project grabbed screen data using the Windows API. The project I was working on would be run on a Linux-based server. Thus, I ported the software to grab screen data using the X11 library instead.

Ported

Sharing the whole desktop.

Not ported

Sharing individual application windows and areas around the cursor.

Known issues

No windows appear with GNOME/Unity, only the wallpaper is shown. Works with LXDE though. (http://stackoverflow.com/questions/37972928/xgetimage-captures-wallpaper-but-no-windows-c-x11)

jsmpeg-vnc-linux's People

Contributors

thesauri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jsmpeg-vnc-linux's Issues

Crashes when connecting to server

When i try to access the server i get this error:
Window size: 1360x768, output size: 1360x768, bit rate: 2040 kb/s

Server started on: http://1.106.71.190:8080/

[swscaler @ 0x557444a6ac00] Warning: data is not aligned! This can lead to a speed loss
fps: 61 (grabbing: 3.00ms, scalin[2022/02/07 23:34:22:3902] E: lws_read_h1: Unhandled state 282
jsmpeg-vnc: /home/aiden/light/libwebsockets/lib/roles/h1/ops-h1.c:297: lws_read_h1: Assertion `0' failed.
Aborted (core dumped)

can't compile on arm linux

^~~~~~~
[100%] Linking C executable jsmpeg-vnc
/usr/bin/ld: CMakeFiles/jsmpeg-vnc.dir/src/server.c.o: in function callback_http': server.c:(.text+0x610): undefined reference to lws_callback_http_dummy'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/jsmpeg-vnc.dir/build.make:159:jsmpeg-vnc] error 1
make[1]: *** [CMakeFiles/Makefile2:76:CMakeFiles/jsmpeg-vnc.dir/all] error 2
make: *** [Makefile:84:all]

pi@raspberrypi:~/Downloads/jsmpeg-vnc-linux-master $ gcc --version
gcc (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I Can't Compile on Linuxmint 18.3 Sylvia

Hello,
This project is very cool.
I want to stream my desktop to my Tablet.

Install packages:

build-essentials
libavcodec-dev
libavutil-dev
libx11-dev
zlib1g-dev
libswscale-dev
libwebsockets-dev

and type "make"

But, compile error with next:

kjm@kjm-HP-15-Notebook-PC ~/jsmpeg-vnc-linux-master/jsmpeg-vnc-linux-master $ make
gcc -o bin/jsmpeg-vnc src/jsmpeg-vnc.c src/encoder.c src/grabber.c src/server.c src/app.c src/jskeycode2x11keycode.c -Isrc/ -Isrc/libwebsockets/ -I/usr/include/x86_64-linux-gnu -lavcodec-ffmpeg -lavutil-ffmpeg -lswscale-ffmpeg -lX11 -lXtst -lz -lwebsockets -std=c11
In file included from /usr/include/uv.h:62:0,
from /usr/include/libwebsockets.h:176,
from src/server.h:4,
from src/app.h:9,
from src/jsmpeg-vnc.c:7:
/usr/include/uv-unix.h:135:9: error: unknown type name ‘pthread_rwlock_t’
typedef pthread_rwlock_t uv_rwlock_t;
^
/usr/include/uv-unix.h:152:9: error: unknown type name ‘pthread_barrier_t’
typedef pthread_barrier_t uv_barrier_t;
^
src/encoder.c: In function ‘encoder_encode’:
src/encoder.c:68:23: warning: passing argument 2 of ‘sws_scale’ from incompatible pointer type [-Wincompatible-pointer-types]
sws_scale(self->sws, in_data, in_linesize, 0, self->in_height, self->frame->da
^
In file included from src/encoder.h:6:0,
from src/encoder.c:4:
/usr/include/x86_64-linux-gnu/libswscale/swscale.h:229:5: note: expected ‘const uint8_t * const* {aka const unsigned char * const*}’ but argument is of type ‘uint8_t ** {aka unsigned char **}’
int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
^
src/server.c:31:85: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
ack_http(struct libwebsocket_context *, struct libwebsocket *, enum libwebsocke
^
src/server.c:31:85: warning: its scope is only this definition or declaration, which is probably not what you want
src/server.c:32:91: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
bsockets(struct libwebsocket_context *, struct libwebsocket *, enum libwebsocke
^
src/server.c:34:38: error: array type has incomplete element type ‘struct libwebsocket_protocols’
static struct libwebsocket_protocols server_protocols[] = {
^
src/server.c: In function ‘server_create’:
src/server.c:60:18: warning: implicit declaration of function ‘libwebsocket_create_context’ [-Wimplicit-function-declaration]
self->context = libwebsocket_create_context(&info);
^
src/server.c:60:16: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
self->context = libwebsocket_create_context(&info);
^
src/server.c: In function ‘server_destroy’:
src/server.c:74:3: warning: implicit declaration of function ‘libwebsocket_context_destroy’ [-Wimplicit-function-declaration]
libwebsocket_context_destroy(self->context);
^
src/server.c: In function ‘server_get_client_address’:
src/server.c:98:2: warning: implicit declaration of function ‘libwebsockets_get_peer_addresses’ [-Wimplicit-function-declaration]
libwebsockets_get_peer_addresses(
^
src/server.c:99:23: warning: implicit declaration of function ‘libwebsocket_get_socket_fd’ [-Wimplicit-function-declaration]
self->context, wsi, libwebsocket_get_socket_fd(wsi),
^
src/server.c: In function ‘server_update’:
src/server.c:107:2: warning: implicit declaration of function ‘libwebsocket_callback_on_writable_all_protocol’ [-Wimplicit-function-declaration]
libwebsocket_callback_on_writable_all_protocol(&(server_protocols[1]));
^
src/server.c:108:2: warning: implicit declaration of function ‘libwebsocket_service’ [-Wimplicit-function-declaration]
libwebsocket_service(self->context, 0);
^
src/server.c: In function ‘server_send’:
src/server.c:123:2: warning: implicit declaration of function ‘libwebsocket_write’ [-Wimplicit-function-declaration]
libwebsocket_write(socket, self->send_buffer, size, (enum libwebsocket_write_p
^
src/server.c:123:60: error: conversion to incomplete type
libwebsocket_write(socket, self->send_buffer, size, (enum libwebsocket_write_p
^
src/server.c: In function ‘server_broadcast’:
src/server.c:134:69: error: conversion to incomplete type
libwebsocket_write(client->socket, self->send_buffer, size, (enum libwebsocke
^
src/server.c: At top level:
src/server.c:144:1: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
) {
^
src/server.c:142:37: error: parameter 3 (‘reason’) has incomplete type
enum libwebsocket_callback_reasons reason,
^
src/server.c: In function ‘callback_websockets’:
src/server.c:145:31: warning: implicit declaration of function ‘libwebsocket_context_user’ [-Wimplicit-function-declaration]
server_t *self = (server_t *)libwebsocket_context_user(context);
^
src/server.c:145:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
server_t *self = (server_t *)libwebsocket_context_user(context);
^
src/server.c: At top level:
src/server.c:179:1: warning: ‘enum libwebsocket_callback_reasons’ declared inside parameter list
) {
^
src/server.c:177:37: error: parameter 3 (‘reason’) has incomplete type
enum libwebsocket_callback_reasons reason, void *user,
^
src/server.c: In function ‘callback_http’:
src/server.c:180:19: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
server_t *self = (server_t *)libwebsocket_context_user(context);
^
src/server.c:186:3: warning: implicit declaration of function ‘libwebsockets_return_http_status’ [-Wimplicit-function-declaration]
libwebsockets_return_http_status(context, wsi, HTTP_STATUS_NOT_FOUND, NULL);
^
src/app.c:6:34: fatal error: X11/extensions/XTest.h: No such file or directory

How can I compile to this?

Linuxmint 18.3 Sylvia(based on ubuntu 16.04 xenial)
gcc 5.4
amd64

Mouse lock nor ESC does not seem to work

Hey, I got your e-mail about this project. Amazing to see you finally blew dust off from this project finally 😄

However, here are few issues I discovered:

  1. Mouse lock does not work - mouse locks but does not really send anything to jsmpeg server. Without mouse lock, mouse events are reported just fine.
  2. Escape button does not work. Must use DISPLAY=:1 xdotool key Escape for that

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.