Skip to content

Latest commit

 

History

History
113 lines (79 loc) · 2.75 KB

File metadata and controls

113 lines (79 loc) · 2.75 KB

Kernel Images Server

A REST API server to start, stop, and download screen recordings.

🛠️ Prerequisites

Required Software

  • Go 1.24.3+ - Programming language runtime
  • ffmpeg - Video recording engine
    • macOS: brew install ffmpeg
    • Linux: sudo apt install ffmpeg or sudo yum install ffmpeg
  • pnpm - For OpenAPI code generation
    • npm install -g pnpm

System Requirements

  • macOS: Uses AVFoundation for screen capture
  • Linux: Uses X11 for screen capture
  • Windows: Not currently supported

🚀 Quick Start

Running the Server

make dev

The server will start on port 10001 by default and log its configuration.

Example use

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

# (recording in progress)

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

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

Additional routes

# Clipboard operations
# | GET /clipboard - Get clipboard content
curl http://localhost:10001/clipboard

# | POST /clipboard - Set clipboard content
curl -X POST -H "Content-Type: application/json" \
  --data '{"type":"text","text":"Hello from clipboard!"}' \
  http://localhost:10001/clipboard

# | GET /clipboard/stream - Stream clipboard changes as SSE
# Keep this running in one terminal
curl -N http://localhost:10001/clipboard/stream

# In another terminal, set clipboard content to see events
curl -X POST -H "Content-Type: application/json" \
  --data '{"type":"text","text":"Clipboard update"}' \
  http://localhost:10001/clipboard

⚙️ 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
FFMPEG_PATH ffmpeg Path to the ffmpeg binary

Example Configuration

export PORT=8080
export FRAME_RATE=30
export MAX_SIZE_MB=1000
export OUTPUT_DIR=/tmp/recordings
./bin/api

API Documentation

  • YAML Spec: GET /spec.yaml
  • JSON Spec: GET /spec.json

🔧 Development

Code Generation

The server uses OpenAPI code generation. After modifying openapi.yaml:

make oapi-generate

🧪 Testing

Running Tests

make test