Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
phoboslab committed Jul 26, 2015
0 parents commit 74e9812
Show file tree
Hide file tree
Showing 115 changed files with 25,272 additions and 0 deletions.
167 changes: 167 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData


## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# jsmpeg-vnc

A low latency, high framerate screen sharing solution, viewable in any modern browser.

[More Info & Demo Video](http://phoboslab.org/log/2015/07/play-gtav-in-your-browser-sort-of)

[Download Binaries](https://github.com/phoboslab/jsmpeg-vnc/releases)


## Usage & Performance Considerations

```
jsmpeg-vnc.exe [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)
Use "Desktop" as the window name to capture the whole Desktop
Full Example:
jsmpeg-vnc.exe -b 2000 -s 1280x720 -f 30 -p 9006 Desktop
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
```

For sharing the whole Desktop, Windows' Aero theme should be disabled as it slows down screen capture significantly. When serving a single window (e.g. games), Aero only has a marginal performance impact and can be left enabled.

Capturing and encoding 1920x1080 video narrowly amounts to 60fps on my system and occupies a whole CPU core. Capturing smaller windows significantly speeds up the process. Depending on your Wifi network quality you may also want to dial down the bitrate for large video sizes.


## Technology & License

This App uses [ffmpeg](https://github.com/FFmpeg/FFmpeg) for encoding, [libwebsockets](https://github.com/warmcat/libwebsockets) for the WebSocket server and [jsmpeg](https://github.com/phoboslab/jsmpeg) for decoding in the browser. Note that the jsmpeg version in this repository has been hacked to get rid of an extra frame of latency. The server sends each frame with a custom header, so the resulting WebSocket stream is not a valid MPEG video anymore.

The client application (the thing that runs in the browser) is very rudimentary. In particular, the mobile version has some quirks and only has touch buttons for the arrow keys, ESC and Enter, though this can be easily extended.

jsmpeg-vnc is published under the [GPLv3 License](http://www.gnu.org/licenses/gpl-3.0.en.html).

If you require my code under a different license, or need some consulting work regarding jsmpeg/jsmpeg-vnc, get in touch: [email protected]
65 changes: 65 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=320, initial-scale=1"/>
<title>jsmpeg-vnc</title>
<style type="text/css">
body {
background: #111;
text-align: center;
margin: 0;
padding: 0;
font-family: sans-serif;
color: #555r;
}
body.desktop .mobile-only { display: none; }
body.mobile .desktop-only { display: none; }

#videoCanvas {
/* Always stretch the canvas to 100%, regardless of its
internal size. */
width: 100%;
height: 100%;
}

.keys {
position: relative;
}
.key {
color: #fff;
float: left;
width: 72px;
height: 48px;
padding-top: 24px;
background-color: #5bcbeb;
position: absolute;
}
.key-small {
height: 28px;
padding-top: 8px;
}
#key-up {left: 40px; top: 0px; }
#key-down {left: 40px; top: 88px; }
#key-left {left: 160px; top: 0px; }
#key-right {left: 240px; top: 0px; }
#key-esc {left: 160px; top: 124px; }
#key-enter {left: 240px; top: 124px; }
</style>
</head>
<body>
<canvas id="videoCanvas" width="320" height="240"></canvas>

<div class="keys mobile-only">
<div class="key" data-code="38" id="key-up">UP</div>
<div class="key" data-code="40" id="key-down">DOWN</div>
<div class="key" data-code="39" id="key-right">RIGHT</div>
<div class="key" data-code="37" id="key-left">LEFT</div>

<div class="key key-small" data-code="27" id="key-esc">ESC</div>
<div class="key key-small" data-code="13" id="key-enter">ENTER</div>
</div>

<script type="text/javascript" src="jsmpg.js"></script>
<script type="text/javascript" src="jsmpg-vnc.js"></script>
</body>
</html>
Loading

0 comments on commit 74e9812

Please sign in to comment.