Repository navigation
media sdk playback stream reader
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.
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.
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();
}| 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 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.
| 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.
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.
- About PlaybackSequenceQuerier: Finding where recordings exist before reading frames.
- About MediaExporter: Producing G64 and G64x export packages from Security Center recordings.
- About MediaPlayer: MediaPlayer WPF control for live, recorded, and local-file playback.
- Overview
- Connecting to Security Center
- SDK certificates
- Referencing SDK assemblies
- ASP.NET hosting
- SDK compatibility
- Migrating to modern .NET
- Entities
- Entity cache
- Entity loading, cache, and query options
- Detecting entity changes
- Entity change event reference
- Transactions
- Security Center events
- Actions
- Security Desk
- Custom events
- Event-to-actions
- Managing macros
- ReportManager
- ReportManager query reference
- Access control raw events
- DownloadAllRelatedData and StrictResults
- Privileges
- Partitions
- Entity write restrictions
- About custom fields
- About video
- About cameras
- Enrolling a video unit
- Ingesting third-party video
- Archiver and auxiliary archiver roles
- Archive transfer
- About access control
- About cardholders and credentials
- About doors, areas, elevators, and access points
- About access rules and schedules
- About access control units and interface modules
- Enrolling an access control unit
- Door templates
- Visitors
- Mobile credentials
- About threat levels
- About alarms
- About incidents
- Maps
- Logging
- Overview
- Localization
- Certificates
- Lifecycle
- Threading
- State management
- Configuration
- Restricted configuration
- Events
- Queries
- Request manager
- Database
- Entity ownership
- Engine extensions
- Entity mappings
- Server management
- Custom privileges
- Custom entity types
- Resolving non-SDK assemblies
- Deploying plugins
- Modern .NET support
- Overview
- Localization
- Certificates
- Creating modules
- Tasks
- Pages
- Components
- Tile extensions
- Services
- Contextual actions
- Custom actions
- Options extensions
- Configuration pages
- Monitors
- Shared components
- Commands
- Extending events
- Map extensions
- Timeline providers
- Image extractors
- Credential encoders
- Credential readers
- Cardholder fields extractors
- Badge printers
- Content builders
- Dashboard widgets
- Incidents
- Logon providers
- Pinnable content builders
- Custom report pages
- Overview
- Getting started
- Media file formats
- MediaPlayer
- VideoSourceFilter
- MediaExporter
- MediaFile
- G64 converters
- FileCryptingManager
- PlaybackSequenceQuerier
- PlaybackStreamReader
- OverlayFactory
- PtzCoordinatesManager
- AudioTransmitter
- AudioRecorder
- AnalogMonitorController
- Camera blocking
- Overview
- Getting started
- Referencing entities
- Entity operations
- About access control in the Web SDK
- About video in the Web SDK
- Users and user groups
- Partitions
- Custom fields
- Custom card formats
- Actions
- Events and alarms
- Incidents
- Reports
- Tasks
- Macros
- Custom entity types
- System endpoints
- Performance guide
- Reference
- Endpoints
- Constants
- Enumerations
- Under the hood
- Troubleshooting