本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}