Skip to content

Commit bd7f884

Browse files
authored
Copy updates for replays! (#25)
We've added and integrated a recording server. Now adding some instructions to make it easier for folks to use!
1 parent ab9e638 commit bd7f884

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,32 @@ You can use the embedded live view to monitor and control the browser. The live
140140
- 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`.
141141
- Replays are currently a work in progress. There is some source code for it throughout the repo.
142142

143+
## Replay Capture
144+
145+
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`
146+
147+
For example:
148+
149+
```bash
150+
cd images/chromium-headful
151+
export IMAGE=kernel-docker
152+
./build-docker.sh
153+
WITH_KERNEL_IMAGES_API=true ENABLE_WEBRTC=true ./run-docker.sh
154+
155+
# 1. Start a new recording
156+
curl http://localhost:10001/recording/start -d {}
157+
158+
# recording in progress - run your agent
159+
160+
# 2. Stop recording
161+
curl http://localhost:10001/recording/stop -d {}
162+
163+
# 3. Download the recorded file
164+
curl http://localhost:10001/recording/download --output recording.mp4
165+
```
166+
167+
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!
168+
143169
## Documentation
144170

145171
This repo powers our managed [browser infrastructure](https://docs.onkernel.com).

images/chromium-headful/run-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN_ARGS=(
2727
)
2828

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

server/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ build: | $(BIN_DIR)
2828
go build -o $(BIN_DIR)/api ./cmd/api
2929

3030
dev: build $(RECORDING_DIR)
31-
OUTPUT_DIR=$(RECORDING_DIR) ./bin/api
31+
OUTPUT_DIR=$(RECORDING_DIR) DISPLAY_NUM=$(DISPLAY_NUM) ./bin/api
3232

3333
test:
3434
go vet ./...
@@ -38,3 +38,12 @@ clean:
3838
@rm -rf $(BIN_DIR)
3939
@rm -f openapi-3.0.yaml
4040
@echo "Clean complete"
41+
42+
DISPLAY_NUM := $(shell \
43+
if [ "$$(uname)" = "Linux" ]; then \
44+
echo "1"; \
45+
elif [ "$$(uname)" = "Darwin" ]; then \
46+
ffmpeg -f avfoundation -list_devices true -i "" 2>&1 | grep "Capture screen" | head -1 | sed 's/.*\[\([0-9]*\)\].*/\1/' 2>/dev/null || echo "2"; \
47+
else \
48+
echo "0"; \
49+
fi)

server/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ A REST API server to start, stop, and download screen recordings.
77
### Required Software
88

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

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

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

3838
# (recording in progress)
3939

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

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

4747
### ⚙️ Configuration
4848

4949
Configure the server using environment variables:
5050

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

5960
#### Example Configuration
6061

0 commit comments

Comments
 (0)