Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ You can use the embedded live view to monitor and control the browser. The live
- The live view is read/write by default. You can set it to read-only by adding `-e ENABLE_READONLY_VIEW=true \` in `docker run`.
- Replays are currently a work in progress. There is some source code for it throughout the repo.

## Replay Capture

You can use the embedded recording server to capture recordings of the entire screen in our headful images. It allows for one recording at a time and can be enabled with `WITH_KERNEL_IMAGES_API=true`

For example:

```bash
cd images/chromium-headful
export IMAGE=kernel-docker
./build-docker.sh
WITH_KERNEL_IMAGES_API=true ENABLE_WEBRTC=true ./run-docker.sh

# 1. Start a new recording
curl http://localhost:10001/recording/start -d {}

# recording in progress - run your agent

# 2. Stop recording
curl http://localhost:10001/recording/stop -d {}

# 3. Download the recorded file
curl http://localhost:10001/recording/download --output recording.mp4
```

Note: the recording file is encoded into a H.264/MPEG-4 AVC video file. [QuickTime has known issues with playback](https://discussions.apple.com/thread/254851789?sortBy=rank) so please make sure to use a compatible media player!

## Documentation

This repo powers our managed [browser infrastructure](https://docs.onkernel.com).
Expand Down
2 changes: 1 addition & 1 deletion images/chromium-headful/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN_ARGS=(
)

if [[ "${WITH_KERNEL_IMAGES_API:-}" == "true" ]]; then
RUN_ARGS+=( -p 444:10001 )
RUN_ARGS+=( -p 10001:10001 )
RUN_ARGS+=( -e WITH_KERNEL_IMAGES_API=true )
fi

Expand Down
11 changes: 10 additions & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build: | $(BIN_DIR)
go build -o $(BIN_DIR)/api ./cmd/api

dev: build $(RECORDING_DIR)
OUTPUT_DIR=$(RECORDING_DIR) ./bin/api
OUTPUT_DIR=$(RECORDING_DIR) DISPLAY_NUM=$(DISPLAY_NUM) ./bin/api

test:
go vet ./...
Expand All @@ -38,3 +38,12 @@ clean:
@rm -rf $(BIN_DIR)
@rm -f openapi-3.0.yaml
@echo "Clean complete"

DISPLAY_NUM := $(shell \
if [ "$$(uname)" = "Linux" ]; then \
echo "1"; \
elif [ "$$(uname)" = "Darwin" ]; then \
ffmpeg -f avfoundation -list_devices true -i "" 2>&1 | grep "Capture screen" | head -1 | sed 's/.*\[\([0-9]*\)\].*/\1/' 2>/dev/null || echo "2"; \
else \
echo "0"; \
fi)
27 changes: 14 additions & 13 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ A REST API server to start, stop, and download screen recordings.
### Required Software

- **Go 1.24.3+** - Programming language runtime
- **FFmpeg** - Video recording engine
- **ffmpeg** - Video recording engine
- macOS: `brew install ffmpeg`
- Linux: `sudo apt install ffmpeg` or `sudo yum install ffmpeg`
- **Node.js/pnpm** - For OpenAPI code generation
- **pnpm** - For OpenAPI code generation
- `npm install -g pnpm`

### System Requirements
Expand All @@ -33,28 +33,29 @@ The server will start on port 10001 by default and log its configuration.

```bash
# 1. Start a new recording
curl http://localhost:10001/recording/start
curl http://localhost:10001/recording/start -d {}

# (recording in progress)

# 2. Stop recording and clean up resources
curl http://localhost:10001/recording/stop
# 2. Stop recording
curl http://localhost:10001/recording/stop -d {}

# 3. Download the recorded file
curl http://localhost:10001/recording/download --output foo.mp4
curl http://localhost:10001/recording/download --output recording.mp4
```

### ⚙️ Configuration

Configure the server using environment variables:

| Variable | Default | Description |
| ------------- | ------- | --------------------------------- |
| `PORT` | `10001` | HTTP server port |
| `FRAME_RATE` | `10` | Default recording framerate (fps) |
| `DISPLAY_NUM` | `1` | Display/screen number to capture |
| `MAX_SIZE_MB` | `500` | Default maximum file size (MB) |
| `OUTPUT_DIR` | `.` | Directory to save recordings |
| Variable | Default | Description |
| -------------- | --------- | ------------------------------------------- |
| `PORT` | `10001` | HTTP server port |
| `FRAME_RATE` | `10` | Default recording framerate (fps) |
| `DISPLAY_NUM` | `1` | Display/screen number to capture |
| `MAX_SIZE_MB` | `500` | Default maximum file size (MB) |
| `OUTPUT_DIR` | `.` | Directory to save recordings |
| `FFMPEG_PATH` | `ffmpeg` | Path to the ffmpeg binary |

#### Example Configuration

Expand Down
Loading