当前位置: 首页>>代码示例>>C#>>正文


C# AMMediaType.SetFormat方法代码示例

本文整理汇总了C#中DirectShow.AMMediaType.SetFormat方法的典型用法代码示例。如果您正苦于以下问题:C# AMMediaType.SetFormat方法的具体用法?C# AMMediaType.SetFormat怎么用?C# AMMediaType.SetFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirectShow.AMMediaType的用法示例。


在下文中一共展示了AMMediaType.SetFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: H264_AnnexB

    /// <summary>
    /// AnnexB formatted h264 bitstream
    /// </summary>
    /// <param name="streamInfo"></param>
    /// <returns></returns>
    public static AMMediaType H264_AnnexB(InputstreamInfo streamInfo)
    {
      int width = (int)streamInfo.Width;
      int height = (int)streamInfo.Height;

      if (streamInfo.ExtraData.Length > 0)
      {
        var codecData = new H264CodecData(streamInfo.ExtraData);

        SPSUnit spsUnit = new SPSUnit(codecData.SPS);
        width = spsUnit.Width();
        height = spsUnit.Height();
      }

      VideoInfoHeader2 vi = new VideoInfoHeader2();
      vi.SrcRect.right = width;
      vi.SrcRect.bottom = height;
      vi.TargetRect.right = width;
      vi.TargetRect.bottom = height;

      int hcf = HCF(width, height);
      vi.PictAspectRatioX = width / hcf;
      vi.PictAspectRatioY = height / hcf;

      vi.BmiHeader.Width = width;
      vi.BmiHeader.Height = height;
      vi.BmiHeader.Planes = 1;
      vi.BmiHeader.Compression = FOURCC_H264;

      AMMediaType amt = new AMMediaType();
      amt.majorType = MediaType.Video;
      amt.subType = MediaSubType.H264;
      amt.temporalCompression = true;
      amt.fixedSizeSamples = false;
      amt.sampleSize = 1;
      amt.SetFormat(vi);
      return amt;
    }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:43,代码来源:MediaTypeBuilder.cs

示例2: E_AC3

    public static AMMediaType E_AC3(InputstreamInfo streamInfo)
    {
      WaveFormatEx wf = new WaveFormatEx();
      wf.wFormatTag = 8192;
      wf.nBlockAlign = 24;
      wf.wBitsPerSample = 32;
      wf.cbSize = 0;

      AMMediaType amt = new AMMediaType();
      AssignStreamInfoFields(streamInfo, ref wf, ref amt);
      amt.majorType = MediaType.Audio;
      amt.subType = MEDIASUBTYPE_DOLBY_DDPLUS;
      amt.temporalCompression = false;
      amt.fixedSizeSamples = true;
      amt.SetFormat(wf);
      return amt;
    }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:17,代码来源:MediaTypeBuilder.cs

示例3: SetFormat

 /// <summary>
 /// Sets AMMediaType format data with Mpeg2VideoInfo and optional extra data.
 /// </summary>
 /// <param name="vi"></param>
 /// <param name="extraData"></param>
 /// <param name="amt"></param>
 static void SetFormat(Mpeg2VideoInfo vi, byte[] extraData, AMMediaType amt)
 {
   int cb = Marshal.SizeOf(vi);
   int add = extraData == null || extraData.Length < 4 ? 0 : extraData.Length - 4;
   IntPtr ptr = Marshal.AllocCoTaskMem(cb + add);
   try
   {
     Marshal.StructureToPtr(vi, ptr, false);
     if (extraData != null)
       Marshal.Copy(extraData, 0, ptr + cb - 4, extraData.Length);
     amt.SetFormat(ptr, cb + add);
     amt.formatType = FormatType.Mpeg2Video;
   }
   finally
   {
     Marshal.FreeCoTaskMem(ptr);
   }
 }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:24,代码来源:MediaTypeBuilder.cs

示例4: AAC_LC

    public static AMMediaType AAC_LC(InputstreamInfo streamInfo)
    {
      WaveFormatEx wf = new WaveFormatEx();
      wf.wFormatTag = 255;
      wf.nBlockAlign = 1;
      wf.wBitsPerSample = 16;
      wf.cbSize = 0;

      AMMediaType amt = new AMMediaType();
      AssignStreamInfoFields(streamInfo, ref wf, ref amt);
      amt.majorType = MediaType.Audio;
      amt.subType = MEDIASUBTYPE_ADTS; // Works better than RAW_AAC1 (tested with Amazon Prime and 7TV)
      amt.temporalCompression = false;
      amt.fixedSizeSamples = true;
      amt.SetFormat(wf);
      return amt;
    }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:17,代码来源:MediaTypeBuilder.cs


注:本文中的DirectShow.AMMediaType.SetFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。