├── .gitignore ├── CMakeLists.txt ├── Dockerfile ├── README.md ├── bin └── client │ ├── index.html │ ├── jsmpg-vnc.js │ └── jsmpg.js └── src ├── app.c ├── app.h ├── encoder.c ├── encoder.h ├── grabber.c ├── grabber.h ├── jskeycode2x11keycode.c ├── jskeycode2x11keycode.h ├── jsmpeg-vnc.c ├── server.c └── server.h /.gitignore: -------------------------------------------------------------------------------- 1 | bin/jsmpeg-vnc 2 | 3 | .DS_STORE 4 | 5 | # Object files 6 | *.o 7 | *.ko 8 | *.obj 9 | *.elf 10 | CMakeLists.txt.user 11 | 12 | # Precompiled Headers 13 | *.gch 14 | *.pch 15 | 16 | # Shared objects (inc. Windows DLLs) 17 | *.dll 18 | *.so 19 | *.so.* 20 | *.dylib 21 | 22 | # Executables 23 | *.exe 24 | *.out 25 | *.app 26 | *.i*86 27 | *.x86_64 28 | *.hex 29 | [Bb]uild 30 | [Bb]in 31 | [Dd]ebug 32 | [Rr]elease 33 | libwebsockets 34 | 35 | # Debug files 36 | *.dSYM/ 37 | *.su 38 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | set(VERSION 1.0.2) 4 | 5 | set(pjname "jsmpeg-vnc") 6 | project (${pjname} VERSION ${VERSION}) 7 | 8 | SET(_HEADERS 9 | src/app.h 10 | src/encoder.h 11 | src/grabber.h 12 | src/jskeycode2x11keycode.h 13 | src/server.h 14 | ) 15 | 16 | SET(_SOURCES 17 | src/app.c 18 | src/encoder.c 19 | src/grabber.c 20 | src/jskeycode2x11keycode.c 21 | src/jsmpeg-vnc.c 22 | src/server.c 23 | ) 24 | 25 | add_executable(${pjname} ${_HEADERS} ${_SOURCES}) 26 | target_link_libraries(${pjname} websockets avcodec avutil swscale X11 Xtst z) 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | ENV TZ=Europe/Stockholm 3 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 4 | 5 | RUN apt-get update 6 | RUN apt-get install -y git 7 | RUN apt-get install -y build-essential 8 | RUN apt-get install -y cmake 9 | RUN apt-get install -y libx11-dev 10 | RUN apt-get install -y libavutil-dev 11 | RUN apt-get install -y libavcodec-dev 12 | RUN apt-get install -y libswscale-dev 13 | RUN apt-get install -y libxtst-dev 14 | RUN apt-get install -y libssl-dev 15 | RUN apt-get install -y pkg-config 16 | RUN apt-get install -y zlib1g-dev 17 | 18 | RUN git clone --branch v4.1-stable --depth 1 https://github.com/warmcat/libwebsockets.git 19 | RUN mkdir -p jsmpeg-vnc-linux/libwebsockets 20 | 21 | WORKDIR jsmpeg-vnc-linux/libwebsockets 22 | 23 | RUN cmake /libwebsockets/ 24 | RUN make 25 | RUN make install 26 | RUN ls -l bin/ 27 | 28 | WORKDIR /jsmpeg-vnc-linux/ 29 | 30 | COPY . ./ 31 | RUN cmake . 32 | RUN make 33 | 34 | ENV LD_LIBRARY_PATH /usr/local/lib 35 | 36 | CMD ["/jsmpeg-vnc-linux/jsmpeg-vnc", "-b", "2000", "-s", "640x480", "-f", "39", "desktop"] 37 | 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jsmpeg-vnc-linux 2 | A semi-complete Linux port of [jsmpeg-vnc](https://github.com/phoboslab/jsmpeg-vnc). 3 | 4 | ## Compiling on Ubuntu 20.04 5 | Install the following packages: 6 | 7 | - build-essential 8 | - libx11-dev 9 | - libx11-dev 10 | - libavutil-dev 11 | - libavcodec-dev 12 | - libswscale-dev 13 | - libxtst-dev 14 | - libssl-dev 15 | - pkg-config 16 | - zlib1g-dev 17 | 18 | In addition to this, compile and install [libwebsockets 4.1](https://github.com/warmcat/libwebsockets/tree/v4.1-stable). 19 | 20 | Then, run the following commands in the root directory: 21 | 22 | ``` 23 | cmake . 24 | make 25 | ``` 26 | 27 | See the [Dockerfile](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). 28 | 29 | ## Running 30 | 31 | ``` 32 | jsmpeg-vnc [options] 33 | 34 | Options: 35 | -b bitrate in kilobit/s (default: estimated by output size) 36 | -s output size as WxH. E.g: -s 640x480 (default: same as window size) 37 | -f target framerate (default: 60) 38 | -p port (default: 8080) 39 | -c crop area in the captured window as X,Y,W,H. E.g.: -c 200,300,640,480 40 | -i enable/disable remote input. E.g. -i 0 (default: 1) 41 | 42 | Use "desktop" as the window name to capture the whole Desktop. Use "cursor" 43 | to capture the window at the current cursor position. 44 | 45 | Example: 46 | jsmpeg-vnc -b 2000 -s 640x480 -f 30 -p 9006 "Quake 3: Arena" 47 | 48 | To enable mouse lock in the browser (useful for games that require relative 49 | mouse movements, not absolute ones), append "?mouselock" at the target URL 50 | i.e: http://:8080/?mouselock 51 | ``` 52 | (Copied from the [parent project](https://github.com/phoboslab/jsmpeg-vnc)) 53 | 54 | ## About 55 | 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 `