- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
不幸的是,我花了很多时间尝试使 DirectShow 的 DTVViewer 示例正常工作,但没有成功。 DVBT 网络的视频格式是 H264,我发现 IFilterGraph
的 IntelliConnect 行为更喜欢使用 Mpeg2 视频格式。
对于那些想看代码的人,就在这里。如果您对 DirectShow 一无所知,我分享了我使用这段代码的经验。本教程的第 5 步和第 6 步中描述了最有可能的问题。
连接过滤器的辅助函数代码:
public static void UnsafeConnectFilters(IFilterGraph2 graph, IBaseFilter source, IBaseFilter dest, Func<AMMediaType, bool> sourceMediaPredicate=null, Func<AMMediaType, bool> destMediaPredicate=null) {
foreach(IPin spin in IteratePinsByDirection(source, PinDirection.Output)) {
if(IsConnected(spin))
continue;
int fetched;
AMMediaType[] sourceTypes=GetMajorType(spin, out fetched);
if(fetched>0) {
Guid sourceType=sourceTypes[0].majorType;
try {
if(sourceMediaPredicate!=null&&!sourceMediaPredicate(sourceTypes[0]))
continue;
foreach(IPin pin in IteratePinsByDirection(dest, PinDirection.Input)) {
if(IsConnected(pin))
continue;
var types=GetMajorType(pin, out fetched);
try {
if(fetched>0) {
Guid destType=types[0].majorType;
if(destMediaPredicate!=null&&!destMediaPredicate(types[0]))
continue;
if(sourceType==destType) {
spin.Connect(pin, types[0]);
return;
}
}
else {
spin.Connect(pin, sourceTypes[0]);
return;
}
}
finally {
}
}
}
finally {
}
}
}
}
有没有人知道:
教程和详情
创建图表
_graph = (IFilterGraph2)new FilterGraph();
我们正在使用 DVBT 网络
IBaseFilter networkProvider = (IBaseFilter) new DVBTNetworkProvider();
... 必须调到 602000KHz@8MHz ONID=1 TSID=1 SID=6
ITuner tuner = (ITuner) networkProvider;
IDVBTuningSpace tuningspace = (IDVBTuningSpace) new DVBTuningSpace();
tuningspace.put_UniqueName("DVBT TuningSpace");
tuningspace.put_FriendlyName("DVBT TuningSpace");
tuningspace.put__NetworkType(typeof (DVBTNetworkProvider).GUID);
tuningspace.put_SystemType(DVBSystemType.Terrestrial);
ITuneRequest request;
tuningspace.CreateTuneRequest(out request);
ILocator locator = (ILocator) new DVBTLocator();
locator.put_CarrierFrequency(602000);
((IDVBTLocator) locator).put_Bandwidth(8);
request.put_Locator(locator);
IDVBTuneRequest dvbrequest = (IDVBTuneRequest) request;
dvbrequest.put_TSID(1);
dvbrequest.put_ONID(1);
dvbrequest.put_SID(6);
_graph.AddFilter(networkProvider, "Network Provider");
创建 mpeg2 解复用器以从单个电视流中获取单独的 EPG/视频/音频/文本流
_mpeg2Demultiplexer = (IBaseFilter) new MPEG2Demultiplexer();
_graph.AddFilter(_mpeg2Demultiplexer, "MPEG-2 Demultiplexer");
现在我们在本地过滤器中搜索 BDA Source Filter,在我的例子中是 IT9135 BDA Fitler
DsDevice[] devicesOfCat =
DsDevice.GetDevicesOfCat(FilterCategory.BDASourceFiltersCategory);
IBaseFilter iteDeviceFilter;
_graph.AddSourceFilterForMoniker(
devicesOfCat[0].Mon, null, devicesOfCat[0].Name, out iteDeviceFilter);
现在连接过滤器:[DVBT Net. Provider]->[BDA Src Filter]->[MPEG2Demux]-> ...
UnsafeConnectFilters(_graph, networkProvider, iteDeviceFilter);
UnsafeConnectFilters(_graph, iteDeviceFilter, _mpeg2Demultiplexer);
两个过滤器必须连接到解复用器,以提供 epg(节目指南数据)。抱歉,我不知道它们具体是什么 doig :P
。它们位于 BDATransportInformationRenderersCategory
类别下。我们尝试通过名称找到它们并将它们连接到 demux
DsDevice[] dsDevices =
DsDevice.GetDevicesOfCat(FilterCategory.BDATransportInformationRenderersCategory);
foreach (DsDevice dsDevice in dsDevices)
{
IBaseFilter filter;
_graph.AddSourceFilterForMoniker(
dsDevice.Mon, null, dsDevice.Name, out filter);
if(dsDevice.Name == "BDA MPEG2 Transport Information Filter")
_bdaTIF = filter;
else if(dsDevice.Name == "MPEG-2 Sections and Tables")
{
_mpeg2SectionsAndTables = filter;
}
UnsafeConnectFilters(_graph, _mpeg2Demultiplexer, filter);
}
现在 demux 连接到 MPEG-2 Sections and Tables
和 BDA MPEG2 Transport Information Filter
。
现在创建 h264 视频类型并将输出添加到该类型的多路分解器的输出引脚
AMMediaType h264 = new AMMediaType();
h264.formatType = FormatType.VideoInfo2;
h264.subType = MediaSubType.H264;
h264.majorType = MediaType.Video;
IPin h264pin;
((IMpeg2Demultiplexer) _mpeg2Demultiplexer).CreateOutputPin(h264, "h264", out h264pin);
下面,我尝试搜索能够处理 H264 视频并位于 DirectShow Filters
类别下的 ffdshow Video Decoder(如 GraphStudio
中)。
DsDevice[] directshowfilters =
DsDevice.GetDevicesOfCat(FilterCategory.LegacyAmFilterCategory);
IBaseFilter ffdshow = null;
foreach (DsDevice directshowfilter in directshowfilters)
{
if(directshowfilter.Name == "ffdshow Video Decoder")
{
_graph.AddSourceFilterForMoniker(
directshowfilter.Mon, null, directshowfilter.Name,
out ffdshow);
break;
}
}
为视频输出创建视频渲染器 ...
_videoRenderer = new VideoRendererDefault();
_graph.AddFilter((IBaseFilter)_videoRenderer, "Video Renderer");
...和音频...
DsDevice defaultDirectSound =
DsDevice.GetDevicesOfCat(FilterCategory.AudioRendererCategory)[0];
_graph.AddSourceFilterForMoniker(
defaultDirectSound.Mon, null, defaultDirectSound.Name,
out _audioRender);
这里我尝试将 demux 的 h264 输出引脚连接到 ffdshow。此方法调用因 AccessViolationException 而失败。我不确定如何将这两者连接在一起 :(
。
注释此行将导致图表开始运行,尽管图表中有断开连接的 ffdshowVideoDecoder 过滤器,但不会显示任何内容。 IntelliConnect 将 Mpeg2 视频输出连接到本地可用的视频解码器,正如我所说,它不会显示任何内容。
// UnsafeConnectFilters(_graph, _mpeg2Demultiplexer, ffdshow, type => type.majorType == MediaType.Video && type.subType == MediaSubType.H264);
ConnectFilters
借鉴了 directshowlib 的 DTVViewer 示例
ConnectFilters();
我把实际调音移到了这里
tuner.put_TuningSpace(tuningspace);
tuner.put_TuneRequest(request);
启动图形并希望显示一些声音或视频
int hr = (_graph as IMediaControl).Run();
DsError.ThrowExceptionForHR(hr);
检查图表是否正在运行......
FilterState pfs;
hr = (_graph as IMediaControl).GetState(1000, out pfs);
DsError.ThrowExceptionForHR(hr);
它表示图形正在运行。
最佳答案
您是否检查过您的 ffdshow 是否启用了 H264/AVC?打开过滤器属性,在“编解码器”部分,应启用 H264/AVC 格式(您也可以禁用 Mpeg2 解码器,以确保它不喜欢这种格式)。
另外,您可以尝试使用另一个 Mpeg2 解复用器。默认的“MPEG-2 解复用器”在不同的环境中表现不同。还有许多其他过滤器可以解复用 TS,如果您可以投资一些钱,我建议您使用 MainConcept 或 Elecard。
关于c# - 强制 Mpeg 2 解复用器使用 ffdshow 渲染 H 264 数字电视视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11201638/
我正在创建一个播放静态 mpeg-DASH 文件的应用程序。我一直在使用 MP4Box 创建 DASH .mp4 和 .mpd 文件。 MPD 文件包含单个 .mp4 文件中的字节范围偏移列表。这工作
我检查了一些 MPEG-4 视频 header ,并在开头看到了一些字节数组,如下所示: 00 00 01 B0 01 00 00 01 B5 89 13 我知道 00 00 01 部分,但 B0 B
我正在尝试实现用于播放受 widevine 保护的视频的 Android 应用程序。我在 Exoplayer 上构建我的应用程序,但我遇到了 MediaDrm 问题。 android.media.Me
我正在寻找区分使用 MPEG-1 和 MPEG-2 容器的文件的具体方法,因为我发现的大多数资源都表明这两个容器的起始代码都是 00 00 01 BA。 我尝试使用 VLC 的 GUI 将 MP4 容
我已经编写了 MPEG-TS 解复用器。它将传输流解包为 PES 数据包。现在我想丢弃所有帧,直到遇到关键帧。 我该怎么做?我应该在每个 PES 帧中找到序列 block 吗? 最佳答案 您应该能够在
我正在尝试能够从 MPEG、MPEG-TS 和 MPEG-PS 文件以及实时流(网络/UDP/RTP 流)中挑选出帧(视频和元数据)。我正在研究使用 JCODEC 来执行此操作,我开始尝试使用 Fra
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
在带有 ARM 和/DSP 的 Android 平台上,哪个解码器会更快:MPEG-4 或 MPEG-2 还是 3GP?为什么? 谢谢 最佳答案 “更快”是一个相对术语。鉴于您问题中的信息,无法回答。
通过 UDP 流式传输,我有一个 MPEG Transport Stream包含: MPEG-2 视频和 MPEG-1 音频,或 H.264 视频和 MPEG-1 音频,或 H.264 视频和 AC3
我对编解码器了解较少。我所知道的编解码器代表解码/编码。在编解码器中将内置在手机中,外部库可以用作替代方案。编解码器对音频\视频起着重要作用,其中格式已编码为文件并解码以播放它们。 问题: Andro
我不知道我需要在哪个标签上问这个问题。 我目前正在研究数字电视广播的 ATSC 标准。我在浏览内容时有疑问。在数字电视广播中,一个带宽将包含多个 channel (服务)。 由广播公司编码和复用的数据
MPEG中节目时钟引用(PCR)的最大值是多少? 据我了解,它源自 27MHz 时钟,定期加载到 42 位寄存器中。 PCR(i)=PCR_Base(i) * 300 + PCR_Ext(i) 其中
我有一些与将 mpeg PES 流(打包)多路复用到 mpeg TS 相关的问题。 为什么 DTS 和 PTS 值包含在 PES 头中,而 PCR 值包含在传输流头中? 如果我们想以某种方式播放 PE
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 1年前关闭。 Improve this questi
。我试图了解 mpd 文件如何播放,我指的是以下数据集: http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys12/Valkaama/MPDs/Valkaa
我正在尝试将几个 .wav 文件转换为 .mp3 格式 所需的 .mp3 格式是: 我尝试使用 FFmpeg 使用以下代码: ffmpeg -i input.wav -vn -ac 2 -b:a 16
我有一个支持 CENC 的 MPD 剪辑,如何在不使用任何特定 DRM 引擎的情况下解密和播放?是否有任何解密算法可用于解密 AES CTR 128 位?如果有,它将用于解密 MPEG-DASH 内容
以下是MPEG2VideoDescriptor的十六进制转储: 06 0e 2b 34 02 53 01 01 0d 01 01 01 01 01 51 00 83 00 00 f3 3c 0a 00
我需要检测文件是否为 MPEG ADTS 文件。我已经四处搜索了它,但无论是我寻找得很糟糕还是其他东西,但我找不到我可以肯定地说某些文件具有 MPEG ADTS 格式的签名。 例如如果文件以这样的签名
我正在开发用于网络吞吐量测试的点对点视频流。两个对等点之间的网络支持低比特率传输。 我使用 OpenCV 为视频流制作了简单的 python 程序。 该程序从网络摄像头抓取视频帧并将其编码为 JPEG
我是一名优秀的程序员,十分优秀!