• Stars
    star
    178
  • Rank 214,989 (Top 5 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎬 Cross-platform hotkey short video capture for games

capsule

capsule augments any game so that pressing a key records a video+audio clip. Those clips can be easily shared later, see this tweet for example.

It's being developed mainly for integration with the itch.io app, but is designed as a separate pair of projects:

libcapsule is responsible for detecting which video & audio APIs a game uses, and intercepting calls to them so that it may capture video and audio frames.

capsulerun is responsible for launching the game, injecting libcapsule, establishing a connection to it, receiving video and audio frames, encoding, and muxing them.

See Build instructions if you know enough to give it a shot :)

Design goals

  • Easy to use - no configuration, hit a key = record (think FRAPS)
  • Fast - should slow down games as little as possible
  • Quality recordings - high FPS, preserve colorspace when possible
  • Desktop audio - all captured gameplay should come with audio
  • Easy sharing - output should be immediately useful (H264/AAC)

Non-goals

Things that are out of scope (ie. that capsule will not officially support):

  • Compositing (more than one video source, etc.)
  • Live-streaming
  • Any platforms that aren't Linux, macOS, or Windows (especially mobile, BSDs, etc.)
  • Long videos - haven't settled on a maximum yet but "a few minutes"
  • Hooking into existing processes - capsulerun must be used to launch game

Status

Core

  • System
    • capsulerun launches child, relays stdout/stderr, injects 32-bit & 64-bit processes properly
    • capsulerun handles child quitting unexpectedly, relays exit code
    • capsulerun & libcapsule communicate via a pair of fifos/named pipes, send frames via shared memory
    • capsulerun has 'headless' mode where it doesn't launch a child, acts as just an encoder (HTML5 games, etc.)
  • Video
    • encoder outputs variable fps h264 video, aac audio, in an mp4 container

Linux

  • Control
    • X11 recording hotkey support (hardcoded to F9)
  • Video
    • OpenGL capture
    • Vulkan capture
  • Audio
    • ALSA: Intercepts ALSA API calls, only F32LE supported so far
    • PulseAudio: Captures monitor of default output device

macOS

  • Control
    • Cocoa recording hotkey support (hardcoded to F9)
  • Video
    • OpenGL capture
    • Vulkan capture
  • Audio
    • CoreAudio: Intercepts API calls, only F32LE supported so far

Windows

  • Control
    • Win32 recording hotkey support (hardcoded to F9)
  • Video
    • Direct3D 9 capture
    • Direct3D 10 capture
    • Direct3D 11 capture (with GPU color conversion & dummy overlay)
    • Direct3D 12 capture
    • Vulkan capture
  • Audio
    • Wasapi: Intercepts API calls, only F32LE supported so far
    • Wasapi fallback: captures default loopback device

Build instructions

This project is being ported to Go & Rust. These instructions are OUTDATED.

capsule is a (set of) CMake projects, which handles things like:

  • Download some dependencies
  • Generating Makefiles, MSVC project files, etc.
  • Doing 32/64-bit tests
  • Bundling required libraries with the final executable

Like typical CMake projects, capsule should be built in a subfolder, never directly in the source tree, as you'll see in platform-specific instructions

Building on Linux

Notes: some distributions ship libav, most distributions ship outdated versions of ffmpeg, save yourself some trouble and build x264 and ffmpeg 3.2+ yourself into a prefix. You can then pass it to cmake with -DCAPSULE_DEPS_PREFIX=/path/to/prefix

64-bit and 32-bit versions are built separately. Example of 64-bit build:

cd /path/to/capsule
mkdir build64
cd build64
cmake ..
make install -j4

capsulerun usage:

/path/to/capsule/build64/dist/capsulerun -- path/to/some/game.x86_64

If nothing's happening, the game isn't using OpenGL, you've got the wrong capsule architecture (64-bit for a 32-bit game for example), or there's something capsule doesn't support yet.

NB: Launcher scripts may give you a bit of trouble at the moment, as capsulerun will establish a connection with the shell and not the game, which will fail. This will be addressed later.

Building on macOS

Pretty much the same as Linux, except you don't need to compile x264 & ffmpeg yourself, a stripped-down home-cooked universal build will be downloaded by cmake.

The resulting capsulerun & libcapsule are universal, which means there's no separate 32-bit/64-bit build processes and they should work with every app, no matter what their architecture.

Example build:

cd /path/to/capsule
mkdir build
cd build
cmake ..
make install -j4

capsulerun supports launching .app bundles and invididual executables. Example usage:

/path/to/capsule/build/dist/capsulerun -- path/to/some/Game.app

Building on Windows

Important notes:

  • Microsoft Visual C++ (MSVC) is needed, 2015 is what we're using internally.
  • CMake shipped with msys2 won't cut it, you need a Windows release of CMake (which includes the Visual Studio project generators): https://cmake.org/

You probably won't get anywhere with an MSVC older than 2015.

From the Visual C++ 2015 Native Build Tools Command Prompt, run:

cd C:\path\to\capsule
mkdir build32
cd build32
cmake -G "Visual Studio 14 2015" ..

To compile, run this from the build32 folder:

msbuild INSTALL.vcxproj

(You can use /maxcpucount:n to speed up the build process, since capsule is broken down in a few projects - where n is the maximum number of CPUs you want to use)

To build a 64-bit version, add Win64 to the generator name (the -G parameter).

C:\path\to\capsule\build32\dist\capsulerun.exe -- some_game.exe

NB: Some games with launchers (for example UE4 games) may give you a bit of trouble at the moment, as capsulerun will establish a connection with the launcher and not the game, which will fail. This will be addressed later.

License

capsule is released under the GPL v2 license, see the LICENSE file.

It uses the following libraries:

Some of its code is derived from the following projects:

Special thanks to:

More Repositories

1

itch

🎮 The best way to play your itch.io games
TypeScript
2,349
star
2

butler

🎩 Command-line itch.io helper
Go
747
star
3

itch.io

🐛 Public itch.io issues tracker and documentation - use support instead for private information!
Makefile
239
star
4

wharf

📡 A protocol to quickly transfer software builds (reference Go implementation)
Go
177
star
5

itch-setup

🌀 An installer for the itch.io desktop app
Go
64
star
6

shoom

🛣️ Cross-platform shared memory access for C++11
C++
41
star
7

sevenzip-go

📦 Go bindings to use 7-zip as a library
Go
34
star
8

wharf-spec

📡 A protocol to quickly transfer software builds
Shell
32
star
9

elevate

🔐 Command-line privilege elevation for Windows
C
23
star
10

wizardry

🍄 A parser, interpreter and compiler for libmagic rule files in golang
Go
18
star
11

smaug

🐲 separate user on windows + firejail on linux + sandbox-exec on macOS
Go
17
star
12

ox

🐂 ox (Os eXtended) contains system utilities for golang that aren't in stock syscall / os
Go
16
star
13

husk

🔩 Rust utilities, usable from Rust or Go
Rust
15
star
14

itchio-i18n

🌏 Translations for the itch.io website
MoonScript
15
star
15

libc7zip

📦 A C interface for https://github.com/itchio/lib7zip
C++
15
star
16

itch-docs

📝 Documentation for the itch.io app
JavaScript
14
star
17

go-itchio

☁ Go bindings for the itch.io API
Go
13
star
18

goff

🍿 Another take on Go FFmpeg bindings
Go
13
star
19

elefant

🐘 A Go library to probe ELF files
Go
11
star
20

zipserver

🎁 A microservice that extracts a .zip file and uploads individual entries
Go
11
star
21

go-brotli

Go bindings for the Brotli compression library (fork of kothar/brotli-go)
C
10
star
22

lib7zip

📦 A fork of https://github.com/stonewell/lib7zip allowing multiple-item extraction
C++
10
star
23

pelican

🐦 A Go library to probe PE files
Go
9
star
24

isolate

🚥 Helper tool to create, manage and run apps with unprivileged users for Windows
C
9
star
25

damage

🎁 A Go toolkit for DMG disk images
Go
8
star
26

itch-lite

Trying out rust + webview
HTML
8
star
27

itch-i18n

🌏 Translations for the itch desktop app
8
star
28

mitch

🐣 mitch is a (m)ock (itch).io server for testing purposes
Go
8
star
29

itch-compatibility-watchlist

🚨 Public issue tracker that receives reports of broken apps using the itch app (high traffic)
7
star
30

press-kit

itch.io press resources
6
star
31

boar

🐗 boar will sniff and dismantle most archives you throw at it
Go
6
star
32

httpkit

🚐 Various HTTP utilities (internal)
Go
6
star
33

savior

🚣 Extractors and Sources with save/resume support
Go
5
star
34

pdfserver

extract and convert pdfs to images on google cloud storage
Go
5
star
35

screw

🔩 Filesystem abstraction
Go
4
star
36

ftl-redux-electron-store

⎋ A fork of redux-electron-store that plays nice with electron-compile's Hot Module Reload
JavaScript
4
star
37

node-butlerd

🐦 Node.js client for butlerd, the butler daemon
TypeScript
4
star
38

dash

💨 dash figures out how to run something
Go
3
star
39

itch-diag

🦑 Diagnostics tool for the itch app
Go
3
star
40

valet

🛎️ Provides butler as a native node addon, via rust
Rust
3
star
41

dllassert

🎭 Asserts that a Windows DLL can be loaded successfully
Shell
2
star
42

hush

Library for silent installation of games
Go
2
star
43

zopf

🍞 tape + sinon + promises + sourcemaps = zopf
JavaScript
2
star
44

cutter

🗡️ A CLI for butlerd, the butler daemon
Go
2
star
45

hades

😈 sqlite persistence layer - backronym for "hades is not an ORM"
Go
2
star
46

fnout

🐚 Identify the contents of files, in particular, executables
JavaScript
2
star
47

cigale

🐜 Jenkins configuration generator
Ruby
2
star
48

intact

Verify a file's integrity from HTTP headers like content-length and x-goog-hash
Go
2
star
49

itchio.js

A javascript client to access the itch.io API from web games
TypeScript
2
star
50

itch-logview

📑 Log viewer for itch v25
Rust
1
star
51

node-asfw

🗔 Node.js bindings for SetForegroundWindow
C++
1
star
52

lake

Pools & files
Go
1
star
53

bob

👷‍♂️ bob helps with CI builds (JS helpers for CI scripts)
JavaScript
1
star
54

arkive

A fork of golang's "archive" package which supports concatenated zips
Go
1
star
55

kitch

👷 Beta builds of the itch app
1
star
56

spellbook

📖 A set of magic files as golang sources, compiled by wizardry
Go
1
star
57

wharf.js

📡 A JavaScript implementation of the wharf protocol
Go
1
star