View Full Version : Constructing Customized DirectShow filter chains
jeffmikels
22nd October 2005, 05:24
The quick and dirty:
I want to programmatically encode dvr-ms files from Windows Media Center 2004 to divx avi.
The details:
I can easily do this in graphedit through the use of the elecard MPEG decoder (the default MPEG decoder won't work). However, if I want to do another show, I have to add that show, and then do all the filter work over again.
I'm looking for a way to programmatically create a custom directshow filter chain using free tools so that I can automate the conversion of dvr-ms files.
I know that graphedit can't be scripted and that Avisynth doesn't allow you to specify what filters are used in "DirectShowSource." However, I'm sure there must be some way to create a direct show filter chain using python, ruby, vbscript or something.
Does anyone have any thoughts on this?
Audionut
22nd October 2005, 07:27
You can save the graph in graphedit.
Hence the only thing you would have to do is load your graph, then delete the input & output files and replace them.
Not 100% sure, but, all "directshowsource" in avisynth does is load the file with the default directshow filters.
Hence, change the merit (http://www.radlight.net/forum/index.php?showtopic=355) for your directshow filters, so that the filters that automatically load are the one's you want to load.
edit: does dgindex open dvr-ms files
foxyshadis
22nd October 2005, 09:25
The good news: Graphedit is finally climbing out of the dark ages and supports an XML in/out format.
The bad news: DirectShowSource doesn't.
So either you can generate these files and manipulate (manually or programmatically) graphedit into saving a normal grf from it, or hex edit the grf. The format doesn't look hard to reverse engineer, in fact half the code is probably in the directshowsource code, but I'm sure it's still going to be a long weekend putting something together to write valid graphs.
Best solution would be to put in a feature request to ian or one of them to add xml graph support to the next version. (Or a custom compile of modified directshowsource.)
For what it's worth, I'd also be interested in this, as I have to use a custom graph to stop unwanted colorspace conversions when using terminal services to start an encode on the beefy server.
Edit: Apparently only the old (2001) version of directshow exported xml graphs, thought the newer 2004 version reads them just fine. Going backwards in technology support it seems.
jeffmikels
22nd October 2005, 20:55
audionut: dgindex will open a dvr-ms file, but it doesn't understand all the extra information microsoft stuffs in there so the video is corrupted.
foxyshadis: I'll have to try messing with the xml graph features. I've never been able to get graphedit to load an xml graph even though I can export them just fine. Hacking the .grf file is something I haven't tried though.
I'll send a message to ian...
edit: How do I reach Ian?
foxyshadis
23rd October 2005, 00:57
http://forum.doom9.org/showthread.php?p=727331 Would probably be the best place to ask. Sh0dan, IanB, or tsp can answer.
Audionut
23rd October 2005, 01:20
Does Neuron2 (aka dgdecode author) know of the problem with dgindex and dvr-ms files?
Let him know of the problems, he is quick to fix things with his wonderful program.
movax
23rd October 2005, 02:57
If you've got some coding expierence, you can use the DirectShow SDK to your advantage. Its interfaces like IGraphBuilder might help.
jeffmikels
24th October 2005, 20:18
I'd love to be able to use the SDK. I think that would be a lot of fun. I really want a dvr-ms frameserver! The problem is that I don't have any tools to do so. At least I don't think so. Can I use the SDK to write DirectShow programs with Python?
IanB
30th October 2005, 01:34
Some notes that may help.
DVR-MS is Digital Rights Managed (DRM) Advanced Stream Format (ASF) wrapping of broadcast media transport streams (mpeg2 etc). Because it is ASF there is not a lot that can legaly be done with it. M$ activly defend their patents on this technology. Authors who publish software to directly parse ASF format files usually get a visit from the M$ Legal arm. Load any ASF derived format into VirtualDub and read the resulting message.
In graphedit (and DirectShowSource) you can only access the needed ASFReader class via the Render File/URL functions. These impose restrictions at M$'s whim. If you get a content protected file then you will not be able to access it via this method. To use the ASFReader class you need a Licence from Microsoft, a Digital Certificate to match and a stack of extra COM complient code to implement the registration and unlocking mechanism.
DirectShowSource (DSS) creates 2 graphs, one for video and one for audio and uses AudoDub() to join them. We do this because we need the audio and video timing to be independant. A Directshow graph only has 1 clock source and 1 current position for all streams.
DSS works by adding our custom renderer for Video or Audio and calling RenderFile. This creates a default graph connected to our renderer. The Video renderer accepts Video streams of subtypes RGB24, RGB32, ARGB, YUY2 and YV12. The Audio renderer accepts Audio streams of subttypes PCM 8bit, 16bit, 24bit, 32bit and IEEE Floating point.
When Loading saved .GRF files you must set either Audio=False or Video=False to match the Video or Audio only graphs loaded respectivly. You have to do the AudioDub() manually. The .GRF file must have 1 only open pin that will directly offer one of the formats and subformats our renderer will accept. We do not negotiate for format converters to be added.
To achieve your goal I recommend you adjust the metrics of your installed codecs so the default directshow graph from RenderFile just loads the codec you want first time. If you are uncomfortable fiddling with the metrics, write two batch files to regsvr32 /u xxx.dll all codecs that load in preference to the one of your choice and regsvr32 xxx.dll those codecs back in after you have done your work.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.