startRecording

suspend fun startRecording(path: String)

Starts copying what plays into a Matroska file at path, with no re-encode.

The file holds the selected video track and every audio and subtitle track, because the player reads all of them. It starts at the next video keyframe, so its first picture decodes.

The recording copies packets as the player reads them, and the player reads ahead of the picture on screen, by up to BufferPolicy.totalDuration. So the file starts and ends that far ahead of what the viewer saw. On a live stream the read-ahead stays short, because the data arrives in real time.

stopRecording, stop and close end the recording without a warning. Every other end warns PlaybackWarning.RecordingStopped: a seek, a move to another queue item, a video track switch, or a write that failed. A seek always ends a recording, because a file with a jump in it is not a recording.

A file already at path is replaced when the first packet is written, not before. When path is the file playing, through any link or spelling of it, the recording ends at that first packet with PlaybackWarning.RecordingStopped and the file is left whole.

Throws

when nothing is open, or when a recording already runs.

when the backend cannot record. The FFmpeg backend records on every platform except the web, where a page has no file to write.

when the file at path cannot be created.