AudioFormatTag Property

Summary
Gets the audio format type for the current stream in the current source media file.
Syntax
C#
C++/CLI
public int AudioFormatTag { get; } 
public: 
property int AudioFormatTag { 
   int get(); 
} 

Property Value

A value (FOURCC Code) representing the audio format type of the current audio stream.

Remarks

Gets the audio format type for the current stream in the current source media file. This property is updated automatically when the CurrentStream property is set to an audio stream. For a list of FOURCC values, refer to the Microsoft documentation on FOURCC Codes. This property will not be updated if the current stream is not an audio stream. The current source media file, found in the SourceFile property, is the file that the MediaInfo object gets information for. The SourceFile property must be set before retrieving information from any of the other MediaInfo properties.

Example
C#
using Leadtools; 
using Leadtools.Multimedia; 
using LeadtoolsMultimediaExamples.Fixtures; 
 
 
public PlayCtrlForm _form = new PlayCtrlForm(); 
public bool _result = false; 
 
public void ResetSourceExample() 
{ 
   // reference the play control 
   PlayCtrl playctrl = _form.PlayCtrl; 
 
   // input file 
   string inWmvFile = Path.Combine(LEAD_VARS.MediaDir, "MediaInfo_Source.wmv"); 
   string inAviFile = Path.Combine(LEAD_VARS.MediaDir, "MediaInfo_Source.avi"); 
             
   try 
   { 
      // create a new media info object 
      MediaInfo mi = new MediaInfo(); 
 
      // get MP3 info 
      mi.SourceFile = inWmvFile; 
 
      // set the info string with general media information 
      Console.WriteLine("General Info"); 
      Console.WriteLine("Title: " + mi.Title); 
      Console.WriteLine("Author: " + mi.Author); 
      Console.WriteLine("Description: " + mi.Description); 
      Console.WriteLine("Rating: " + mi.Rating); 
      Console.WriteLine("Copyright: " + mi.Copyright); 
      Console.WriteLine(); 
 
      // reset the source 
      mi.ResetSource(); 
 
      // get AVI info 
      mi.SourceFile = inAviFile; 
 
      Console.WriteLine("General Info"); 
      Console.WriteLine("File: " + mi.SourceFile); 
      Console.WriteLine("File Size: " + mi.SourceFileSize); 
      Console.WriteLine("Format: " + mi.SourceFormat + "(" + mi.SourceFormatName + ")"); 
      Console.WriteLine("Duration: " + mi.SourceDuration); 
      Console.WriteLine("Real Bit-rate: " + mi.SourceBitRate); 
      Console.WriteLine("Format Type: " + mi.SourceMediaType.FormatType); 
      Console.WriteLine(); 
 
      Console.WriteLine("Source Filter Info"); 
                
      var s = mi.SourceFilter; 
      IntPtr ptr = Marshal.GetIUnknownForObject(s); 
      Console.WriteLine(string.Format("Address of Object Pointer: 0x{0:X}", ptr.ToInt64())); 
 
      Console.WriteLine("ClassID: " + mi.SourceFilterClassID); 
      Console.WriteLine("Name: " + mi.SourceFilterName); 
 
      Console.WriteLine("Streams Info"); 
      for ( int streamIndex = 0; streamIndex < mi.OutputStreams; streamIndex++ ) 
      { 
         mi.CurrentStream = streamIndex; 
         Console.WriteLine("Stream Index: " + streamIndex); 
         Console.WriteLine("Type: " + mi.StreamType + "(" + mi.StreamTypeName); 
         Console.WriteLine("Subtype: " + mi.StreamSubtype + "(" + mi.StreamSubtypeName); 
         Console.WriteLine("Format Type: " + mi.StreamMediaType.FormatType); 
 
         if (mi.StreamTypeName == "Video") 
         { 
            Console.WriteLine("Width: " + mi.VideoWidth + " pixels"); 
            Console.WriteLine("Height: " + mi.VideoHeight + " pixels"); 
            Console.WriteLine("Bit Count: " + mi.VideoBitCount + " bits per pixel"); 
            Console.WriteLine("Frame Count: " + mi.VideoFrames); 
            Console.WriteLine("Frame Rate: " + mi.VideoFrameRate + "frames per second"); 
            Console.WriteLine("Compression: " + mi.VideoCompression); 
            Console.WriteLine("Bit-rate: " + mi.VideoBitRate + "kbps"); 
            Console.WriteLine("Duration: " + mi.StreamDuration + "seconds"); 
            Console.WriteLine(); 
         } 
         else if (mi.StreamTypeName == "Audio") 
         { 
            Console.WriteLine("Format Tag: " + mi.AudioFormatTag); 
            Console.WriteLine("Channels: " + mi.AudioChannels); 
            Console.WriteLine("Frequency: " + mi.AudioSamplesPerSec + " samples per second"); 
            Console.WriteLine("Sample Size: " + mi.AudioBitsPerSample + " bits per sample"); 
            Console.WriteLine("Average Rate: " + mi.AudioAvgBytesPerSec + "bytes per second"); 
            Console.WriteLine("Duration: " + mi.StreamDuration + "seconds"); 
            Console.WriteLine(); 
         } 
      } 
 
      // media info outputted to console, set result to true 
      _result = true; 
 
      // reset the source 
      mi.ResetSource(); 
 
      // set the result to what we expect 
      _result = (mi.SourceFile == null); 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string MediaDir = @"C:\LEADTOOLS23\Media"; 
} 
Requirements

Target Platforms

See Also

Reference

MediaInfo Class

MediaInfo Members

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Multimedia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.