Repository navigation
media sdk video source filter
VideoSourceFilter is a headless playback component that delivers decoded video frames to your code instead of rendering them to a control. It exposes the same playback members as MediaPlayer (live, archive, seek, pause, capabilities, statistics) and adds the FrameDecoded event for frame-level access.
AudioVideoSourceFilter inherits from VideoSourceFilter and adds AudioDataPlayed for synchronized PCM audio. Use it when the workflow needs both decoded video and decoded audio aligned to the same stream.
VideoSourceFilter requires a Platform SDK Engine that is logged on to a Directory before you call Initialize. The Security Center license must include the Media SDK option; Initialize fails when it does not.
VideoSourceFilter opens a streaming session like MediaPlayer and decodes incoming frames in the background. For each decoded video frame, it raises FrameDecoded with a FrameDecodedEventArgs that carries the decoded buffer.
FrameDecodedEventArgs and the DecodedFrameContent it carries are tied to native buffers that the SDK owns. Your handler must dispose the event argument before returning. Calling Data, Y, U, V, Width, Height, or DataSize after disposal throws ObjectDisposedException. An IntPtr value read from Y, U, or V, or a Bitmap obtained from GetBitmap(), before disposal is different: the exception does not retroactively invalidate it. The native memory it points to can be freed or handed to a later frame, so using that captured value after disposal silently reads the wrong data. Copy what you need before disposing.
FrameDecoded can be raised many times per second. Slow handlers create back-pressure on decoding; copy what you need, enqueue work to a processing pipeline, and dispose the event payload before returning.
using Genetec.Sdk.Media;
VideoSourceFilter filter = new VideoSourceFilter();
filter.ForceYUVOutput = true;
filter.FrameDecoded += OnFrameDecoded;
filter.Initialize(engine, cameraGuid);
filter.PlayLive();The constructor has an overload that accepts a WPF Panel for hardware-decoder workflows that require a video container.
Set ForceYUVOutput before Initialize. Once initialized, output format choices are fixed.
private static void OnFrameDecoded(
object sender,
FrameDecodedEventArgs e)
{
using (e)
{
if (e.IsBlocked || e.DecodedFrameContent == null)
{
return;
}
DecodedFrameContent frame = e.DecodedFrameContent;
using RgbDecodedFrame rgbFrame = frame.GetBitmap();
if (rgbFrame?.Bitmap == null)
{
return;
}
ProcessBitmap(rgbFrame.Bitmap, e.FrameTime);
}
}
FrameDecodedEventArgs member |
Description |
|---|---|
IsBlocked |
true when the frame is blocked by Security Center camera blocking. DecodedFrameContent is null in this case. Treat blocking as an access decision, not a missing frame. |
IsKeyFrame |
true when this is a key frame. Use to align processing to key-frame boundaries (encoding, segment start). |
FrameTime |
UTC timestamp of the decoded frame. |
DecodedFrameContent |
The decoded frame buffer. Disposed when the event argument is disposed. |
One decoded video frame. Implements IDisposable; disposal is driven by the parent FrameDecodedEventArgs.
| Member | Description |
|---|---|
Format |
DecodedFrameFormat value: Rgb32, Nv12, Yuv420, Yuv422, or Unknown. Treat as read-only. |
Width, Height
|
Decoded picture dimensions in pixels. |
Data, DataSize
|
Raw decoded bytes and size. Format-dependent layout. |
Rgb32Stride |
RGB32 row width in pixels. Multiply by 4 to get the stride in bytes. Valid when Format is Rgb32. |
Y, U, V
|
YUV plane pointers (IntPtr). Valid when Format is Yuv420, Yuv422, or Nv12. |
StrideY |
Number of bytes between consecutive Y rows. For Nv12, also use this value between consecutive rows of the interleaved UV plane. |
StrideUV |
Number of bytes between consecutive U rows or V rows for Yuv420 and Yuv422. For Nv12, use StrideY. |
IsDisposed |
Defensive check before reading buffers. The parent event argument controls actual lifetime. |
GetBitmap() |
Convert to an RgbDecodedFrame regardless of format. Returns null when the format is Unknown or unsupported. |
GetBitmapFromRgbRawData() |
Get an RGB frame when Format is Rgb32 only. |
GetRgbFrameFromYuvFrame() |
Get an RGB frame from Nv12, Yuv420, or Yuv422. |
RgbDecodedFrame wraps a System.Drawing.Bitmap and implements IDisposable. Dispose it independently from the event argument; both must be disposed.
AudioVideoSourceFilter inherits everything from VideoSourceFilter and adds AudioDataPlayed for decoded audio. Set IsAudioEnabled before Initialize.
AudioVideoSourceFilter avFilter = new AudioVideoSourceFilter();
avFilter.IsAudioEnabled = true;
avFilter.FrameDecoded += OnFrameDecoded;
avFilter.AudioDataPlayed += OnAudioDataPlayed;
avFilter.Initialize(engine, cameraGuid);
avFilter.PlayLive();AudioFrameDecodedEventArgs and the DecodedAudioFrameContent it carries follow the same disposal rule as the video event argument.
private static void OnAudioDataPlayed(
object sender,
AudioFrameDecodedEventArgs e)
{
using (e)
{
DecodedAudioFrameContent audio = e.DecodedAudioFrameContent;
ProcessPcmAudio(
audio.Data,
audio.DataOffset,
audio.DataSize,
e.FrameTime);
}
}DecodedAudioFrameContent exposes PCM audio bytes through Data, DataOffset, and DataSize.
VideoSourceFilter and AudioVideoSourceFilter use the same playback commands as MediaPlayer: PlayLive, PlayArchive(DateTime), Pause, ResumePlaying, Seek(DateTime), Rewind, Stop. Use UTC for all time values, the same way you would with MediaPlayer.
For archive processing, decide on the time window and cancellation strategy before starting playback. Live playback runs until you call Stop or dispose the filter.
The filters expose FeatureCapabilities, EventCapabilities, StatisticsCapabilities, PlayerStateChanged, StreamingConnectionStatusChanged, and the same cache/buffering members as MediaPlayer. Use them to drive UI state, enable or disable optional behavior, and show stream issues. Capability flags reflect the current stream connection; before a stream connects, they are empty.
The filters inherit AllowSharedPlayback from PublicMediaPlayerProxy (their abstract base). Default is false: the filter does not share its local playback cache with other source-filter components.
Set AllowSharedPlayback = true before Initialize when multiple source filters target the same camera in the same process and should share the playback cache. Changing the property after Initialize throws.
MediaPlayer does not expose AllowSharedPlayback; this property is specific to source-filter components.
These rules apply to every frame handler. Re-accessing a disposed DecodedFrameContent throws ObjectDisposedException. An IntPtr or Bitmap obtained before disposal is not invalidated by that exception; using it afterward can silently read stale or reused memory.
- Dispose
FrameDecodedEventArgs(orAudioFrameDecodedEventArgs) before the handler returns. Useusing (e)so disposal happens even on exceptions. - Do not store
DecodedFrameContent,DecodedAudioFrameContent,RgbDecodedFrame, or the event argument beyond the handler. Copy data into application-owned buffers if a later thread needs to process it. - Dispose
RgbDecodedFramereturned byGetBitmap()independently from the event argument. - When
e.IsBlockedistrue,DecodedFrameContentisnull. Branch onIsBlockedbefore accessing frame content. - Stop and dispose the filter when processing ends.
- About MediaPlayer: MediaPlayer WPF control for live, recorded, and local-file playback.
- About camera blocking: Evaluating camera-blocking state in Media SDK components.
- About PlaybackStreamReader: Reading raw recorded video, audio, or metadata frames as data.
- 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