コード例 #1
0
 /// <summary>
 /// Queries the available bitrates for a given encoding output type, sample rate and number of channels
 /// </summary>
 /// <param name="audioSubtype">Audio subtype - a value from the AudioSubtypes class</param>
 /// <param name="sampleRate">The sample rate of the PCM to encode</param>
 /// <param name="channels">The number of channels of the PCM to encode</param>
 /// <returns>An array of available bitrates in average bits per second</returns>
 // Token: 0x0600093A RID: 2362 RVA: 0x0001AAE0 File Offset: 0x00018CE0
 public static int[] GetEncodeBitrates(Guid audioSubtype, int sampleRate, int channels)
 {
     return((from br in (from mt in MediaFoundationEncoder.GetOutputMediaTypes(audioSubtype)
                         where mt.SampleRate == sampleRate && mt.ChannelCount == channels
                         select mt.AverageBytesPerSecond * 8).Distinct <int>()
             orderby br
             select br).ToArray <int>());
 }
コード例 #2
0
 /// <summary>
 /// Tries to find the encoding media type with the closest bitrate to that specified
 /// </summary>
 /// <param name="audioSubtype">Audio subtype, a value from AudioSubtypes</param>
 /// <param name="inputFormat">Your encoder input format (used to check sample rate and channel count)</param>
 /// <param name="desiredBitRate">Your desired bitrate</param>
 /// <returns>The closest media type, or null if none available</returns>
 // Token: 0x0600093F RID: 2367 RVA: 0x0001AE7C File Offset: 0x0001907C
 public static MediaType SelectMediaType(Guid audioSubtype, WaveFormat inputFormat, int desiredBitRate)
 {
     return((from mt in MediaFoundationEncoder.GetOutputMediaTypes(audioSubtype)
             where mt.SampleRate == inputFormat.SampleRate && mt.ChannelCount == inputFormat.Channels
             select new
     {
         MediaType = mt,
         Delta = Math.Abs(desiredBitRate - mt.AverageBytesPerSecond * 8)
     } into mt
             orderby mt.Delta
             select mt.MediaType).FirstOrDefault <MediaType>());
 }