ManagesRecording
Recording concern of {@see \Discord\Voice\VoiceClient}: {@see record()} / {@see stopRecording()} and the per-user file-sink lifecycle.
Tags
Table of Contents
Methods
- record() : void
- Starts recording incoming voice audio.
- stopRecording() : void
- Stops an in-progress recording started by {@see record()}.
Methods
record()
Starts recording incoming voice audio.
public
record([RecordingFormat|null $format = null ][, callable(string): string|null $outputPath = null ]) : void
When called with no arguments, raw PCM and Opus frames are emitted via the
channel-pcm and channel-opus events for the caller to handle.
When called with a format and output path callback, the voice client automatically writes per-user audio files. The callback receives the user ID string and must return an absolute or relative file path string.
Supported formats:
RecordingFormat::PCM— raw s16le PCM; emitschannel-pcmevents AND writes raw bytes to per-user files when$outputPathis providedRecordingFormat::WAV— per-user WAV files via pure-PHP WavWriterRecordingFormat::OGG— per-user OGG Opus files via ffmpeg (requires ffmpeg)
Parameters
- $format : RecordingFormat|null = null
-
Output format. Null = PCM events only (no file writing).
- $outputPath : callable(string): string|null = null
-
Callback returning the file path for a given user ID. Required for WAV and OGG formats. Optional for PCM (when provided, raw PCM bytes are written to the file).
Tags
stopRecording()
Stops an in-progress recording started by {@see record()}.
public
stopRecording() : void
Finalises every per-user writer, closes recording processes and PCM handles, and clears all receive-stream, decoder and speaking state.