I have looked at both sources and the code seems straight forward. The problem I am having is that after I create the output pins I map the streams. If I look at my graph with Graphedit the mappings don't exist. When I do mapstreams I don't get an error, but the stream mappings don't show up either and I can't connect other filters. I have tested building the entire graph in graphedit and it works fine. The following is the code for the mpeg2 demux:
Then later after I connect the input to the MPEG-2 Demux filter I map the streams like:
hr = videoStreamMap.MapStreamId(0xE0, MPEG2Program.ElementaryStream, 0, 0);
if (hr < 0)
{
Logger.DebugMessageLog("Could not map stream id 0xe0 to video pin");
}
hr=audioStreamMap.MapStreamId(0xC0,MPEG2Program.ElementaryStream,0,0);if(hr< 0){
Logger.DebugMessageLog("Could not map stream id 0xc0 to audio pin");}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was searching posts about MPEG2VideoInfo, and found this one. I understand
this is over two years old.
But, I just have a quick question. Where is MPEG2VideoInfo struct? I have
search all namespaces under DirectShowLib, but not able to find it.
Apparently, Naildawg has used it in the posted C# code. How could I use it?
What I need to do is similar to yours: to preview some MPEG2(H.264) Video. One
step is to create an output pin of MPEG2 Demux. In an MS example (C++ code), I
found that I have to use MPEG2VideoInfo to alloc memory for
AMMediaType.formatPtr, but I could not find it under current DirectShowLib
namespace.
Thank you very much
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for the late thanks. I was caught by a few other emergencies and have
just got a chance to look at your message carefully.
It seems that we have to define MPEG2VideoInfo by ourselves. Are there any
special reasons for not defining it in DirectShowLib?
Also, according to http://beta.codeproject.com/KB/directx/MPEG2_Capture_Devic
e.aspx,
we should be able to use graphedt to build a graph to preview MPEG2 Video. But
I can't open MPEG2 Demux properties dialog. (There is always an error message
mentioning that the properties can't be shown.) I have followed the
instruction to install DirectX, but it still doesn't work. Any idea for that?
Many thanks indeed.
kjj902
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for bothering you again with a few questions. I am try using graphedt to
build a graph to preview a H.264 camera, but I don't know much details about
that camera, so a lot of guess work.
I am quite sure it pushes MPEG2 TS, since GraphEdt filter properties dialog
shows that the SubType is MPEG2_TRANSPORT. I also think that the TS packet
contains nothing but one H.264 Elementary Stream.
However, I don't know the PID of the H.264 PES. Is there a way for me to find
out the PID?
Also, I am confused when adding a new output pin to MPEG2 demux using
GraphEdt. I think I should choose "MPEG2 Program Video" for the media type,
right? This "Program Video" has nothing to do with MPEG2 Program Stream,
right? In the PID mappings, I think I should choose "Elementary Stream (A/V
only), right?
I can play with GraphEdt to understand the second question, but I stuck on
finding out PID. There are so many choices. How could we find it out??
Thank you very much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does anyone have any sample source for configuring the MPEG2-demux. Adding output pins, setting the AMMediaTypes for the pins etc..
I managed to get it working by remarking the following lines from the above example:
//videoType.formatType = FormatType.Mpeg2Video;
//videoType.fixedSizeSamples = false;
//videoType.temporalCompression = true;
//videoType.sampleSize = 0;
Interesting. Odd, but interesting.
Glad it's working for you.
Well, there is some code in Samples\BDA\DTVViewer\BDAGraphBuilder.cs that might be useful. And there is some (really ugly) code in:
http://directshownet.cvs.sourceforge.net/directshownet/directshowlib/Test/v1.3/IMPEG2StreamIdMapTest.cs?view=markup
http://directshownet.cvs.sourceforge.net/directshownet/directshowlib/Test/v1.3/IMPEG2PIDMapTest.cs?revision=1.2&view=markup
However, your best bet might be to look at http://www.codeproject.com/directx/MPEG2_Capture_Device.asp. While it is in c++, it is probably close to what you are trying to do. You can at least read it to see how things work.
I have looked at both sources and the code seems straight forward. The problem I am having is that after I create the output pins I map the streams. If I look at my graph with Graphedit the mappings don't exist. When I do mapstreams I don't get an error, but the stream mappings don't show up either and I can't connect other filters. I have tested building the entire graph in graphedit and it works fine. The following is the code for the mpeg2 demux:
IPin audioPin;
Then later after I connect the input to the MPEG-2 Demux filter I map the streams like:
hr = videoStreamMap.MapStreamId(0xE0, MPEG2Program.ElementaryStream, 0, 0);
if (hr < 0)
{
Logger.DebugMessageLog("Could not map stream id 0xe0 to video pin");
}
Hi, Naildawg and Snarfle,
I was searching posts about MPEG2VideoInfo, and found this one. I understand
this is over two years old.
But, I just have a quick question. Where is MPEG2VideoInfo struct? I have
search all namespaces under DirectShowLib, but not able to find it.
Apparently, Naildawg has used it in the posted C# code. How could I use it?
What I need to do is similar to yours: to preview some MPEG2(H.264) Video. One
step is to create an output pin of MPEG2 Demux. In an MS example (C++ code), I
found that I have to use MPEG2VideoInfo to alloc memory for
AMMediaType.formatPtr, but I could not find it under current DirectShowLib
namespace.
Thank you very much
Doing a search in this forum, I see definitions for it in two different
threads:
Plus of course you can find it on msdn:
http://msdn.microsoft.com/en-
us/library/dd390707%28VS.85%29.aspx
Hi, Snarfle,
Sorry for the late thanks. I was caught by a few other emergencies and have
just got a chance to look at your message carefully.
It seems that we have to define MPEG2VideoInfo by ourselves. Are there any
special reasons for not defining it in DirectShowLib?
Also, according to http://beta.codeproject.com/KB/directx/MPEG2_Capture_Devic
e.aspx,
we should be able to use graphedt to build a graph to preview MPEG2 Video. But
I can't open MPEG2 Demux properties dialog. (There is always an error message
mentioning that the properties can't be shown.) I have followed the
instruction to install DirectX, but it still doesn't work. Any idea for that?
Many thanks indeed.
kjj902
Sounds like you have failed to regsvr32 proppage.dll.
Thank you very much indeed. After I resvr32 proppage.dll, everything works
fine now. Many thanks.
Hi, snarfle,
Sorry for bothering you again with a few questions. I am try using graphedt to
build a graph to preview a H.264 camera, but I don't know much details about
that camera, so a lot of guess work.
I am quite sure it pushes MPEG2 TS, since GraphEdt filter properties dialog
shows that the SubType is MPEG2_TRANSPORT. I also think that the TS packet
contains nothing but one H.264 Elementary Stream.
However, I don't know the PID of the H.264 PES. Is there a way for me to find
out the PID?
Also, I am confused when adding a new output pin to MPEG2 demux using
GraphEdt. I think I should choose "MPEG2 Program Video" for the media type,
right? This "Program Video" has nothing to do with MPEG2 Program Stream,
right? In the PID mappings, I think I should choose "Elementary Stream (A/V
only), right?
I can play with GraphEdt to understand the second question, but I stuck on
finding out PID. There are so many choices. How could we find it out??
Thank you very much.
Sorry, I'm not enough of an expert on H.264 or MPEG transport streams to be
able to help here.
Still thank you very much in any case. I will try posting a separate thread to
see whether anyone else has any ideas.