IC Imaging Control ActiveX

AviCompressor.CompressorData Property

AviCompressor.CompressorData Property

Returns or sets the data of an AviCompressor.
Public CompressorData As Variant

The returned data should only be used to store the state of the codecs. The data in the array is not to be modified. If inconsistent data is passed to the codec, an error is returned. Furthermore, the data of one codec will not match each other.


The following example shows how to save and load codec data into and from a binary file. The codec which is currently used, must be declared globally. If it is declared locally in the sub procedure, it would loose its settings after exiting the sub procedure, because it would be removed from memory. The complete example can be found in the samples directory in Saving Codec Properties.

' Global declaration of the AviCompressor object
Dim Codec As AviCompressor

Save the data from a codec that was selected in a combo box.

Private Sub cmdSaveData_Click()
    Dim Data() As Byte ' Dynamic array for the data stream.

    Open "test.bin" For Binary As #1 ' Must be opened binary!

    ' Save the length of the codec's name.
    Put #1, , Len(Codec.Name)

    ' Save the name of the codec.
    Put #1, , Codec.Name

    ' Save the byte count of the data stream. It is used
    ' when data is loaded from file to resize the dynamic array.
    Put #1, , Codec.CompressorDataSize

    ' Get the data from the codec.
    Data = Codec.CompressorData

    ' Save the data to the file.
    Put #1, , Data
    Close #1
End Sub

Load the previously saved data and assign it to a codec.

Private Sub cmdLoadData_Click()
    Dim Data() As Byte      ' Dynamic array for the data stream.
    Dim Length As Long      ' Length of the data stream.
    Dim NameLength As Long  ' Length of the codec's name.
    Dim CodecName As String ' Name of the codec.
    Dim i As Integer

    Open "test.bin" For Binary As #1 ' Must be opened binary!

    ' Read the length of the codec's name.
    Get #1, , NameLength

    ' Allocate memory for the name.
    CodecName = String(NameLength, " ")

    ' Read the name of the codec.
    Get #1, , CodecName

    ' Compare the names.
    If CodecName = Codec.Name Then
        ' Read the length of the follwing data.
        Get #1, , Length

        ' Resize the data array to Length.
        ReDim Data(Length)

        ' Read the codec data from the file.
        Get #1, , Data

        ' Assign the read data to the codec object.
        Codec.CompressorData = Data
        MsgBox "The saved data does not match to the used codec." + Chr(13) + _
               "saved: " + CodecName + Chr(13) + _
               "used: " + Codec.Name
    End If
    Close #1
End Sub
See Also: AviCompressor, AviCompressor.CompressorDataSize

<< AviCompressor

Get in touch with us

About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us