Skip to content

media sdk playback stream reader

Andre Lafleur edited this page Oct 8, 2026 · 6 revisions

About PlaybackStreamReader

PlaybackStreamReader connects to a recorded stream and reads raw frames in sequence. It exposes archived video, audio, or metadata as a frame-level data feed instead of a rendered player or an export package.

Use PlaybackStreamReader when the application needs the recorded bytes for analytics, custom investigation tools, or batch processing. To play video, use MediaPlayer. For an export package, use MediaExporter. To find out where recordings exist before reading, use PlaybackSequenceQuerier.

How reading works

Create a reader through CreateVideoReader, CreateAudioReader, or CreateReader, depending on the kind of stream. Call ConnectAsync, and then call SeekAsync(DateTime) to position the reader at a UTC time. Read frames in a loop with ReadAsync.

ConnectAsync does not complete until at least one playback source is available. Call ConnectAsync before SeekAsync or ReadAsync: the reader cannot seek until it is connected to a playback source.

ReadAsync returns a RawDataContent object for each frame. The reader signals end-of-recording by returning null from ReadAsync once. Calling ReadAsync again past the end without seeking throws EndReachedException.

PlaybackStreamReader implements IDisposable and exposes a DisposeAsync() method that returns Task for asynchronous disposal. Use await reader.DisposeAsync() for async cleanup, or reader.Dispose() in synchronous contexts.

PlaybackStreamReader

using Genetec.Sdk.Media;
using Genetec.Sdk.Media.Reader;

PlaybackStreamReader reader =
    PlaybackStreamReader.CreateVideoReader(engine, cameraGuid);

try
{
    await reader.ConnectAsync();
    await reader.SeekAsync(startTimeUtc);

    while (true)
    {
        using RawDataContent content = await reader.ReadAsync();

        if (content == null)
        {
            break;
        }

        ProcessFrame(
            content.FrameTime,
            content.Data,
            content.Format);
    }
}
finally
{
    await reader.DisposeAsync();
}

Factory methods

Method Use it for
CreateVideoReader(IEngine, Guid cameraGuid) Recorded video for the camera.
CreateAudioReader(IEngine, Guid cameraGuid) Recorded audio for the camera.
CreateReader(IEngine, Guid cameraGuid, Guid streamGuid) A specific metadata stream associated with the camera.

Each factory has an overload that accepts a playback source GUID as the last parameter. Use it when the application must read from one specific archive source instead of any available source. Find the playback source GUID with PlaybackSequenceQuerier QuerySequencesBySourcesAsync.

ReadAsync results

ReadAsync returns one of:

Result Meaning Handle by
RawDataContent A frame is available. Read the data, dispose the content, continue the loop.
null The reader reached the end of recording (first time). Break the loop, or call SeekAsync to resume from a different time.

After the end of recording, reposition the reader with SeekAsync before calling ReadAsync again. If the reader is no longer connected to a playback source, reconnect with ConnectAsync or end the workflow. Do not call ReadAsync on a disposed reader.

RawDataContent

Member Type Description
FrameTime DateTime UTC timestamp of the frame.
IsKeyFrame bool true when the frame is a key frame.
Data ArraySegment<byte> Raw frame bytes. Use Data.Count for the size.
Format EncodingType Codec the stream uses.
MediaType Guid Stream type identifier (video, audio, or metadata).
PlaybackSourceGuid Guid Source the frame was read from.
Sequence DateTimeRange The recorded sequence range that contains the frame.

RawDataContent implements IDisposable. Use using when reading a frame so it disposes regardless of how the loop exits. Do not store RawDataContent past the iteration; copy the data into application-owned buffers if a later thread needs to process it.

Cancellation

ConnectAsync, SeekAsync, and ReadAsync accept a cancellation token. Pass one when the user can end the read loop by closing the view, switching cameras, or ending the analytics window.

See also

Platform SDK

Plugin SDK

Workspace SDK

Media SDK

Macro SDK

Web SDK

Synergis RIO

Media Gateway

Genetec Web Player

Clone this wiki locally