Skip to content

media sdk media file

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

About MediaFile

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.

How inspection works

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.

Supported formats

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.

MediaFile

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;
}

UniqueSource

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.

MediaFile.ContainedFile

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.

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