|
| 1 | +--- |
| 2 | +title: Track recording |
| 3 | +description: Record separate audio tracks for selected RealtimeKit participants and download per-participant WebM files. |
| 4 | +pcx_content_type: how-to |
| 5 | +sidebar: |
| 6 | + order: 9 |
| 7 | +products: |
| 8 | + - realtime |
| 9 | +--- |
| 10 | + |
| 11 | +Track recording records each participant's audio as a separate WebM file in RealtimeKit's Cloudflare R2 bucket. Use track recording when you need isolated speaker tracks for post-processing, transcription, compliance workflows, or audio analysis. |
| 12 | + |
| 13 | +Composite recording creates one mixed meeting recording. Track recording creates one file per recorded participant peer. |
| 14 | + |
| 15 | +:::note |
| 16 | + |
| 17 | +Track recording currently supports audio tracks only. Video track recording is in development. |
| 18 | + |
| 19 | +::: |
| 20 | + |
| 21 | +## Availability and limits |
| 22 | + |
| 23 | +Track recording has the following requirements and limits: |
| 24 | + |
| 25 | +| Limit | Description | |
| 26 | +| --------------------- | ----------------------------------------------------- | |
| 27 | +| Active meeting | The meeting must have an active live session. | |
| 28 | +| Media kind | Only `audio` layers are recorded. | |
| 29 | +| Participant selection | Pass up to `100` values in `user_ids`. | |
| 30 | +| Storage | Files are uploaded to the RealtimeKit bucket. | |
| 31 | +| File retention | RealtimeKit bucket download URLs expire after 7 days. | |
| 32 | + |
| 33 | +## Start track recording |
| 34 | + |
| 35 | +To start track recording, call `POST /recordings/track` with the meeting ID. |
| 36 | + |
| 37 | +If you omit `layers`, RealtimeKit records all participant audio. You can pass an audio layer to set a file name prefix for generated files. |
| 38 | + |
| 39 | +```bash |
| 40 | +curl --request POST \ |
| 41 | + --url https://api.cloudflare.com/client/v4/accounts/<account_id>/realtime/kit/<app_id>/recordings/track \ |
| 42 | + --header 'Authorization: Bearer <api_token>' \ |
| 43 | + --header 'Content-Type: application/json' \ |
| 44 | + --data '{ |
| 45 | + "meeting_id": "97440c6a-140b-40a9-9499-b23fd7a3868a", |
| 46 | + "layers": { |
| 47 | + "default": { |
| 48 | + "media_kind": "audio", |
| 49 | + "file_name_prefix": "speaker" |
| 50 | + } |
| 51 | + } |
| 52 | +}' |
| 53 | +``` |
| 54 | + |
| 55 | +The response includes a recording ID. Use this ID to stop or fetch the recording. |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "success": true, |
| 60 | + "data": { |
| 61 | + "recording": { |
| 62 | + "id": "fff40c6a-140b-40a9-9499-b23fd7a3868a", |
| 63 | + "meeting_id": "97440c6a-140b-40a9-9499-b23fd7a3868a", |
| 64 | + "status": "INVOKED", |
| 65 | + "type": "TRACK", |
| 66 | + "output_file_name": "{{file_name_prefix}}_{{user_id}}_{{peer_id}}_{{stream_kind}}_{{media_kind}}_{{date_time}}.webm" |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +## Record selected participants |
| 73 | + |
| 74 | +Pass `user_ids` to record only specific participants. RealtimeKit records current and future participant peers whose `user_id` matches the allowlist. |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "meeting_id": "97440c6a-140b-40a9-9499-b23fd7a3868a", |
| 79 | + "user_ids": ["user-123", "user-456"] |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +## Set file name prefix |
| 84 | + |
| 85 | +Use `file_name_prefix` to prefix every generated track recording file. |
| 86 | + |
| 87 | +```json |
| 88 | +{ |
| 89 | + "meeting_id": "97440c6a-140b-40a9-9499-b23fd7a3868a", |
| 90 | + "layers": { |
| 91 | + "default": { |
| 92 | + "media_kind": "audio", |
| 93 | + "file_name_prefix": "speaker" |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +If you omit `layers`, RealtimeKit uses `default` as the file name prefix. |
| 100 | + |
| 101 | +## Stop track recording |
| 102 | + |
| 103 | +Use the recording update endpoint to stop a track recording. |
| 104 | + |
| 105 | +```bash |
| 106 | +curl --request PUT \ |
| 107 | + --url https://api.cloudflare.com/client/v4/accounts/<account_id>/realtime/kit/<app_id>/recordings/<recording_id> \ |
| 108 | + --header 'Authorization: Bearer <api_token>' \ |
| 109 | + --header 'Content-Type: application/json' \ |
| 110 | + --data '{ |
| 111 | + "action": "stop" |
| 112 | +}' |
| 113 | +``` |
| 114 | + |
| 115 | +Track recording also stops when the meeting session ends. |
| 116 | + |
| 117 | +After track recording stops, RealtimeKit uploads the per-participant WebM files and moves the recording to `UPLOADED`. |
| 118 | + |
| 119 | +## Download track files |
| 120 | + |
| 121 | +Track recording uses the same recording status lifecycle as composite recording. To monitor status, refer to [Monitor Recording Status](/realtime/realtimekit/recording-guide/monitor-status/). |
| 122 | + |
| 123 | +When the recording reaches `UPLOADED`, fetch the recording details or listen for the `recording.statusUpdate` webhook. The `download_url` field contains the recorded WebM files for participant peers. |
| 124 | + |
| 125 | +```json |
| 126 | +{ |
| 127 | + "download_url": [ |
| 128 | + { |
| 129 | + "layer_name": "default", |
| 130 | + "download_urls": { |
| 131 | + "speaker_user-123_peer-456_peer_audio_1760000000000.webm": { |
| 132 | + "download_url": "https://example.com/presigned-url" |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | + ] |
| 137 | +} |
| 138 | +``` |
| 139 | + |
| 140 | +File names use this format: |
| 141 | + |
| 142 | +```txt |
| 143 | +{{file_name_prefix}}_{{user_id}}_{{peer_id}}_{{stream_kind}}_{{media_kind}}_{{date_time}}.webm |
| 144 | +``` |
| 145 | + |
| 146 | +The `date_time` value is the Unix timestamp in milliseconds when the file was generated. |
0 commit comments