Repository navigation
media sdk media file
MediaFile inspects an existing G64, G64x, or MP4 file on disk. It exposes the unique sources represented by the file and the contained files with their start time, end time, time zone, and watermark status. The available values depend on the file format.
MediaFile does not retrieve recordings from Security Center. It operates purely on a file that already exists. Use MediaExporter to produce G64 or G64x files. Use G64ToMp4Converter to produce MP4 files.
The MediaFile constructor opens the file to inspect its metadata. A missing file throws FileNotFoundException, and empty or invalid files can also cause the constructor to throw. Use try and catch blocks to handle these exceptions. The UniqueSources and ContainedFiles collections can be empty even when the constructor succeeds. Check whether these collections contain entries before using their metadata.
After construction, the file's structure is available through UniqueSources and ContainedFiles. MediaFile does not need an Engine and does not require a connection to Security Center; inspection is local.
The values returned by MediaFile differ by format.
| Format | Sources and files | Security Center identifiers and names | Recording details |
|---|---|---|---|
| G64x | Returns one or more UniqueSources and ContainedFiles. |
Returns the source and encoder identifiers and names stored in the package. | Returns the recording times, time zone, and watermark status for each contained file. |
| G64 | Returns one UniqueSource and one ContainedFile. |
Returns source and encoder identifiers. CollectionName and EncoderName are empty. |
Returns the recording times, time zone, and watermark status. |
| MP4 | Returns one UniqueSource and one ContainedFile. |
For MP4 files created by G64ToMp4Converter, returns the retained source and encoder identifiers. CollectionName and EncoderName are empty. |
Returns the recording times and time zone. IsWatermarked is false. |
MP4 files created by G64ToMp4Converter also contain Windows and iTunes-compatible display tags, including the camera name and recording time information. MediaFile does not return these display tags or expose MP4 metadata streams. Use an MP4 metadata reader to retrieve the display tags. For details, see MP4 metadata.
Important
For an MP4 file that was not created by G64ToMp4Converter, do not treat Collection or Encoder as Security Center entity identifiers. MediaFile can return generated values for these members.
using Genetec.Sdk.Media;
var mediaFile = new MediaFile(filePath);
foreach (UniqueSource source in mediaFile.UniqueSources)
{
bool containsVideo = source.IsVideo;
bool containsAudio = source.IsAudio;
string encoderName = source.EncoderName;
Guid encoderGuid = source.Encoder;
}
foreach (MediaFile.ContainedFile contained in mediaFile.ContainedFiles)
{
DateTime startUtc = contained.StartTime;
DateTime endUtc = contained.EndTime;
bool isWatermarked = contained.IsWatermarked;
}A UniqueSource identifies one source stream inside the file: a camera, an audio source, or a metadata stream. Use it when the application needs to show which sources are present, what media types they contain, and how to present them in a review UI.
| Member | Type | Description |
|---|---|---|
IsVideo |
bool |
true when the source carries video. |
IsAudio |
bool |
true when the source carries audio. |
Encoder |
Guid |
Identity of the encoder that produced the source. |
EncoderName |
string |
Encoder name stored in a G64x package. Empty for G64 and MP4 files. |
Origin |
Guid |
Identity of the server or resource that produced the stream. |
Collection |
Guid |
Identifier of the logical group of streams the source belongs to, usually a camera. |
CollectionName |
string |
Collection name stored in a G64x package. Empty for G64 and MP4 files. |
MediaType |
Guid |
Media type identifier (video, audio, or metadata). |
Usage |
Guid |
Identifies the version or variant of the stream. |
ContainedFile describes one file represented by the input. A G64x package can contain several ContainedFile entries for multiple cameras or time ranges. G64 and MP4 files return one entry.
| Member | Description |
|---|---|
Filename |
Name of the elementary file inside a G64x package, or the input file path for G64 and MP4 files. |
StartTime |
UTC start time of the contained recording. |
EndTime |
UTC end time of the contained recording. |
TimeZone |
TimeZoneInfo recorded when the file was created. |
IsWatermarked |
Watermark status for G64 and G64x recordings. For MP4 files, the value is false. |
UniqueSource |
The UniqueSource this file belongs to. |
- About media file formats: Choosing between G64x, G64, and MP4 output.
- About MediaExporter: Producing G64 and G64x export packages from Security Center recordings.
- About G64 converters: Converting G64 and G64x packages to ASF or MP4, including MP4 metadata behavior.
- About FileCryptingManager: Encrypting and decrypting local media files.
- 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