Loading...
Loading...
Asciinema v3 .cast file format reference. TRIGGERS - cast format, asciicast spec, event codes, parse cast file.
npx skill4agent add terrylica/cc-skills asciinema-cast-formatPlatform: All platforms (documentation only)
| Field | Type | Required | Description |
|---|---|---|---|
| int | Yes | Format version (always 2 for v3 recordings) |
| int | Yes | Terminal width in columns |
| int | Yes | Terminal height in rows |
| int | No | Unix timestamp of recording start |
| float | No | Total duration in seconds |
| string | No | Recording title |
| object | No | Environment variables (SHELL, TERM) |
| object | No | Terminal color theme |
{
"version": 2,
"width": 120,
"height": 40,
"timestamp": 1703462400,
"duration": 3600.5,
"title": "Claude Code Session",
"env": { "SHELL": "/bin/zsh", "TERM": "xterm-256color" }
}[timestamp, event_type, data]| Code | Name | Description | Data Format |
|---|---|---|---|
| Output | Terminal output (stdout) | String |
| Input | Terminal input (stdin) | String |
| Marker | Named marker for navigation | String (marker name) |
| Resize | Terminal resize event | |
| Exit | Extension for custom data | Varies |
[0.5, "o", "$ ls -la\r\n"]
[1.2, "o", "total 48\r\n"]
[1.3, "o", "drwxr-xr-x 12 user staff 384 Dec 24 10:00 .\r\n"]
[5.0, "m", "file-listing-complete"]
[10.5, "r", "80x24"]/usr/bin/env bash << 'CALC_TIME_EOF'
HEADER_TIMESTAMP=$(head -1 recording.cast | jq -r '.timestamp')
EVENT_OFFSET=1234.5 # From event array
ABSOLUTE=$(echo "$HEADER_TIMESTAMP + $EVENT_OFFSET" | bc)
date -r "$ABSOLUTE" # macOS
# date -d "@$ABSOLUTE" # Linux
CALC_TIME_EOF/usr/bin/env bash << 'HEADER_EOF'
head -1 recording.cast | jq '.'
HEADER_EOF/usr/bin/env bash << 'DURATION_EOF'
head -1 recording.cast | jq -r '.duration // "unknown"'
DURATION_EOF/usr/bin/env bash << 'COUNT_EOF'
tail -n +2 recording.cast | jq -r '.[1]' | sort | uniq -c
COUNT_EOF/usr/bin/env bash << 'OUTPUT_EOF'
tail -n +2 recording.cast | jq -r 'select(.[1] == "o") | .[2]'
OUTPUT_EOF/usr/bin/env bash << 'MARKERS_EOF'
tail -n +2 recording.cast | jq -r 'select(.[1] == "m") | "\(.[0])s: \(.[2])"'
MARKERS_EOF/usr/bin/env bash << 'TIME_EOF'
TARGET_TIME=60 # seconds
tail -n +2 recording.cast | jq -r "select(.[0] >= $TARGET_TIME and .[0] < $((TARGET_TIME + 1))) | .[2]"
TIME_EOF| File Size | Line Count | Approach |
|---|---|---|
| <100MB | <1M | jq streaming works fine |
| 100-500MB | 1-5M | Use |
| 500MB+ | 5M+ | Convert to .txt first with asciinema |
/usr/bin/env bash << 'STREAM_EOF'
# Stream process large files
jq --stream -n 'fromstream(1|truncate_stream(inputs))' recording.cast | head -1000
STREAM_EOFasciinema convert -f txt recording.cast recording.txt1. [Reference] Identify .cast file to analyze
2. [Header] Extract and display header metadata
3. [Events] Count events by type (o, i, m, r)
4. [Analysis] Extract relevant event data based on user need
5. [Navigation] Find markers or specific timestamps if needed| Issue | Cause | Solution |
|---|---|---|
| jq parse error | Invalid NDJSON in .cast file | Check each line is valid JSON with |
| Header missing duration | Recording in progress | Duration added when recording ends |
| Unknown event type | Custom extension event | Check for |
| Timestamp out of order | Corrupted file | Events should be monotonically increasing |
| Large file jq timeout | File too big for in-memory | Use |
| Markers not found | No markers in recording | Markers are optional; not all recordings have them |
| Wrong version number | Older cast format | This skill covers v2 format (asciinema v3+) |
| Empty output from tail | File has only header | Recording may be empty or single-line |