简体   繁体   English

DirectShow视频流立即结束(m_pMediaSample为NULL)

[英]DirectShow video stream ends immediately (m_pMediaSample is NULL)

I have a Video renderer redived from CBaseVideoRenderer . 我有一个从redived视频渲染器CBaseVideoRenderer The renderer is used in a graph that receives data from a live source (BDA). 渲染器用于从实时源(BDA)接收数据的图形中。 It looks like the connections are established properly, but the video rendering immediately ends because there is no sample. 看起来连接已正确建立,但是由于没有样本,因此视频渲染立即结束。 However, audio Rendering works, ie I can hear the sound while DoRenderSample of my renderer is never called. 但是,音频渲染可以正常工作,即,在从未调用渲染器的DoRenderSample的同时,我可以听到声音。

Stepping through the code in the debugger, I found out that in CBaseRenderer::StartStreaming , the stream ends immedately, because the member m_pMediaSample is NULL . 逐步执行调试器中的代码,我发现在CBaseRenderer::StartStreaming ,流立即结束,因为成员m_pMediaSampleNULL If I replace my renderer with the EVR renderer, it shows frames, ie the stream is not ending before the first frame for the EVR renderer, but only for my renderer. 如果我用EVR渲染器替换渲染器,它将显示帧,即,流不会在EVR渲染器的第一帧之前结束,而仅在我的渲染器中结束。

Why is that and how can I fix it? 为什么会这样,我该如何解决? I implemented (following the sample from http://www.codeproject.com/Articles/152317/DirectShow-Filters-Development-Part-Video-Render ) what I understand as the basic interface ( CheckMediaType , SetMediaType and DoRenderSample ), so I do not see any possibility to influence what is happening here... 我实现了(按照http://www.codeproject.com/Articles/152317/DirectShow-Filters-Development-Part-Video-Render的示例)作为基本接口( CheckMediaTypeSetMediaTypeDoRenderSample )理解的CheckMediaType ,看不到有什么可能影响这里发生的事情...

Edit: This is the graph as seen from the ROT: 编辑:这是从ROT中看到的图形: 运行对象表条目

What I basically try to do is capturing a DVB stream that uses VIDEOINFOHEADER2 , which is not supported by the standard sample grabber. 我基本上想做的是捕获使用VIDEOINFOHEADER2的DVB流,这是标准样本采集器不支持的。 Although the channel is a public German TV channel without encryption, could it be that this is a DRM issue? 尽管该频道是未加密的德国公共电视频道,但这是否是DRM问题?

Edit 2: I have attached my renderer to another source (a Blackmagic Intensity Shuttle). 编辑2:我已将渲染器附加到另一个源(Blackmagic Intensity Shuttle)。 It seams that the source causes the issue, because I get samples in the other graph. 它似乎是由源引起的,因为我在另一个图中得到了样本。

Edit 3: Following Roman's Suggestion, I have created a transform filter. 编辑3:根据Roman的建议,我创建了一个转换过滤器。 The graph looks like 该图看起来像

图形与采集卡的旋转

an has unfortunately the same problem, ie I do not get any sample ( Transform is not called). 不幸的是,它有同样的问题,即我没有得到任何样本(未调用Transform )。

Looks like your decoder or splitter isn't demuxing the video frames. 看起来您的解码器或分离器没有对视频帧进行解胶。 Look further up the chain to see what filters are supplying your renderer pin with data, chances are its only recognising audio. 进一步查看链,看看哪些过滤器为您的渲染器针提供数据,可能是它只能识别音频。

Try dropping the file into Graphedit (there's a better one on the web BTW) and see what filters it creates. 尝试将文件放入Graphedit(Web BTW上有一个更好的文件),并查看它创建了哪些过滤器。

Then look at the samples in the DirectShow SDK. 然后查看DirectShow SDK中的示例。

You supposedly chose wrong path of fetching video frames out of media pipeline. 您应该选择从媒体管道中提取视频帧的错误路径。 So you are implementing a "network renderer", something that terminates the pipeline to further send data to network. 因此,您正在实现“网络渲染器”,它终止了管道以进一步将数据发送到网络。

A renderer which accepts the feed sounds appropriate. 接受提要的渲染器听起来很合适。 Implementing a custom renderer, however, is an untypical task and then there is not so much information around on this. 但是,实现自定义渲染器是一项不典型的任务,因此关于此的信息不多。 Additionally, a fully featured renderer is typically equipped with sample scheduling part, which end of stream delivery - things relatively easy to break when you customize it through inheriting from base classes. 此外,功能齐全的渲染器通常配备有示例计划部分,该部分位于流交付的末尾-当您通过从基类继承进行自定义时,相对容易破坏。 That is, while the approach sounds good, you might want to compare it to another option you have, which is... 也就是说,虽然这种方法听起来不错,但您可能希望将其与您拥有的另一种选择进行比较,即...

A combination of Sample Grabber + Null Renderer, two standard filters, which you can attach your callback to and get frames having the pipeline properly terminated. Sample Grabber + Null Renderer和两个标准过滤器的组合,您可以将其附加到回调并获得正确终止管道的帧。 The problem here is that standard Sample Grabber does not support VIDEOINFOHEADER2 . 这里的问题是标准的Sample Grabber不支持VIDEOINFOHEADER2 With another video decoder you could possibly have the feed decoded info VIDEOINFOHEADER , which is one option. 使用其他视频解码器,您可能可以将Feed解码后的信息VIDEOINFOHEADER一个选项。 And then improvement of Sample Grabber itself is another solution: DirectX SDK Extras February 2005 (dxsdk_feb2005_extras.exe) was the SDK which included a filter similar to standard Sample Grabber called Grabber \\DirectShow\\Samples\\C++\\DirectShow\\Filters\\Grabber . 然后改进Sample Grabber本身是另一个解决方案: DirectX SDK Extras 2005年2月(dxsdk_feb2005_extras.exe)是SDK,其中包含类似于标准Sample Grabber的过滤器,称为Grabber \\DirectShow\\Samples\\C++\\DirectShow\\Filters\\Grabber It is/was available in source code and provided with a good description text file. 它可以/已经在源代码中提供,并提供了一个很好的描述文本文件。 It is relatively easy to extend to allow it accept VIDEOINFOHEADER2 and make payload data available to your application this way. 扩展它相对容易,以使其接受VIDEOINFOHEADER2并以这种方式使有效负载数据可用于您的应用程序。

The easiest way to get data out of a DirectShow graph, if youњre not going to use MultiMedia Streaming, is probably to write your own TransInPlace filter, a sub-variety of a Transform filter. 如果您不打算使用MultiMedia Streaming,则从DirectShow图形中获取数据的最简单方法可能是编写自己的TransInPlace过滤器,该过滤器是Transform过滤器的一个子类。 Then connect this filter to the desired stream of data you wish to monitor, and then run, pause, seek, or otherwise control the graph. 然后将此过滤器连接到您希望监视的所需数据流,然后运行,暂停,搜索或以其他方式控制图形。 The data, as it passes through the transform filter, can be manipulated however you want. 通过转换过滤器的数据可以根据需要进行操作。 We call this kind of filter, a Њsample grabberћ. 我们称这种过滤器为“样本采集器”。 Microsoft released a limited-functionality sample grabber with DX8.0. 微软发布了带有DX8.0的功能有限的样本采集卡。 This filter is limited because it doesnњt deal with DV Data or mediatypes with a format of VideoInfo2. 该过滤器受到限制,因为它不处理格式为VideoInfo2的DV数据或媒体类型。 It doesnњt allow the user to receive prerolled samples. 它不允许用户接收预卷样品。 (Whatњs a preroll sample? See the DX8.1 docs) Its ЊOneShotћ mode also has some problems. (什么是预卷示例?请参阅DX8.1文档)其“ OneShot”模式也存在一些问题。

To add to this, the Grabber sample is pretty simple itself - perhaps 1000 lines of code all together, including comments. 除此之外,Grabber示例本身非常简单-可能包括注释的1000行代码在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM