---
title: "DSReader Class"
canonical: https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_DSReader.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# DSReader Class
 
This class is used to read frames from video files using DirectShow framework.
 
**Namespace:** [Aurigma.GraphicsMill.Codecs](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
 **Assembly:** Aurigma.GraphicsMill.Codecs.MediaProcessor (in Aurigma.GraphicsMill.Codecs.MediaProcessor.dll)
 
## Syntax
  
```
Public NotInheritable Class DSReader _Inherits FormatReader _Implements IFrameEnumerator, ITimeReader
```
 
```csharp
public sealed class DSReader : FormatReader, IFrameEnumerator, ITimeReader
```
 
## Remarks
  
DirectShow opens all files that can be played with Windows Media Player plus files in several more formats. This framework is recommended to use when reading MPEG, MPEG-2 and AVI. For the list of supported file formats, see the [System Requirements](https://www.graphicsmill.com/docs/gm5/MediaProcessorSystemRequirements.htm.md) section of the manual.
 
Video files are represented as a sequence of images which are called *frames*. The DSReader class allows extracting frames using the [LoadFrame(Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_FormatReader_LoadFrame_1_e1836fc4.htm.md) method. Also, the reader object can be interpreted as a collection of frames, and therefore the frames can be enumerated using the `foreach` statement.
 
A DSReader object can be used not only to read video data, but also to extract some information about the opened file. For example, you can get:
 
- Duration (the [Duration](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_DSReader_Duration.htm.md) property).
- Number of frames per second (the [FramesPerSecond](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_DSReader_FramesPerSecond.htm.md) property).

In general the reader usage workflow should be as follows:
 
1. Create a DSReader instance.
2. Open the reader using the [Open(String)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_FormatReader_Open_1_bb3a7a4f.htm.md) method. 
**Note**
You cannot get any data from the reader until you open it on some file.
3. If necessary, read the [Duration](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_DSReader_Duration.htm.md) and [FramesPerSecond](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_DSReader_FramesPerSecond.htm.md) properties.
4. Iterate through each frame in the reader using the [LoadFrame(Int32)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_FormatReader_LoadFrame_1_e1836fc4.htm.md) method. It will return a [DSFrame](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_DSFrame.htm.md) class instance. To extract the image from the frame, use the [GetBitmap(Bitmap)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Codecs_Frame_GetBitmap_1_fd4033ef.htm.md) method.
 
    To get the total number of the frames in the reader, read the [FrameCount](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_FormatReader_FrameCount.htm.md) property.
 
## Examples
 This example shows the general pattern of working with the reader. ```
Private Sub DSReaderUsage(ByVal aPath As String)
    Dim aReader As DSReader = New DSReader(aPath)
    'Work with the reader
    aReader.Dispose()
End Sub
``````csharp
private void DSReaderUsage(String aPath)
{
    DSReader aReader = new DSReader(aPath);
    //Work with the reader
    aReader.Dispose();
}
```
 
## Inheritance Hierarchy
  
- [System.Object](http://msdn2.microsoft.com/en-us/e5kfa45b)
    - [Aurigma.GraphicsMill.SyncHandler](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_SyncHandler.htm.md)
        - [Aurigma.GraphicsMill.Codecs.FormatReader](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_FormatReader.htm.md)
            - Aurigma.GraphicsMill.Codecs.DSReader
 
## Thread Safety
 Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
 
## Object Model

[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill.Codecs.MediaProcessor_ObjectModel_10.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_DSReader.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill.Codecs.MediaProcessor_ObjectModel_11.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IFrame.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill.Codecs.MediaProcessor_ObjectModel_8.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IFrame.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel1.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill.Codecs.MediaProcessor_ObjectModel_9.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IFrame.htm.md)
  
## See Also

### Reference

- [DSReader Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_Codecs_DSReader.htm.md)
- [Aurigma.GraphicsMill.Codecs Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
