Sign in to follow this  
slyterence

DirectShow, DMO's and other woes

Recommended Posts

Hi, I need to write a program which can perform jitter correction on amateur digital video, for university. I wanted to get it working for AVI files, which would have been easy enough, as I could have just used the VFW code I wrote to process AVI's for the game I'm making. However, I've been told I need to work with MPEG's, which complicates matters significantly. I've been doing a lot of reading lately about MPEG, DirectShow, DMO's, filter graphs, etc... and I'm still not sure what exactly I should use for this project. Basically, I need to be able to access several frames of video simultaneously, so that I can predict and compensate the motion. Now, from what I understand, MPEG (2?) uses fields, not frames, which is just one of the complications. The deadline on this project is drawing closer, and I don't really want to waste my time implementing a number of DirectShow filters if I'm not going to be able to use them. So, what I want to know is : Can DirectShow help me? The actual jitter correction algorithm I'll work on myself once I have access to the frames of video, but I need some advice over what route to take to get those frames. I've thought of three (seemingly) different options: 1) Should I use a filter graph in a DirectShow application? I might need to create a kind of "feedback loop" where the output of a series of filters is hooked back up as one of the inputs. Can I do this? 2) Alternatively, are there free DMO's available that will allow me to do everything from opening, decoding and then reencoding the file once I've adjusted it? DMO's can apparently be used without needing to be tied to DirectShow graphs. Would this be a better solution? 3) Should I perhaps use a filter graph, and then just write a DMO for the jitter correction step, and insert it into the graph? Also, I'm *fairly* proficient in C++, but I've never used COM before, and the one project I've done with C# was very pleasant (Web-server -> Database interface). So, if possible, I'd like to write this project in C#. However, the DirectX C++ documentation I have mentions nothing about C#, and says only that Visual Basic exposes a limited subset of DirectShow features. What is the status with regards to C#? There is, of course, another option, which is to find a free MPEG encoder/decoder, and forget about DirectX completely, but I haven't had much luck with that so far. Any suggestions to any (or all) of my questions is greatly appreciated. Thank you $£¥

Share this post


Link to post
Share on other sites
You need to build a filter of your own that places it self between the video output of the video decoder (doesn«t really matter if it's mpeg avi or whatever because you'll be working with RGB or YUY2) and make the output framerate double so you can blend between 2 frames to remove the choppiness.

Graph example

Source->Avi/Mpeg Demux->Video Decoder-> YOUR FILTER -> Video Renderer.

now your filter should be receiving at 25fps and outputing at 50fps.

outputed frames example:
1st = 1st frame received
2nd = 1st and 2nd frame received blended
3rd = 2nd frame received
4th = 2nd and 3rd frame received blended
5th = 3rd frame received
... and so on

this way I think you should be able to remove choppiness.
but you said that you've never used COM before... I guess you should learn it fast.

Share this post


Link to post
Share on other sites
Thank's for replying. I have a few more questions tho...

I'm still not sure whether to use DirectShow filters or a set of DirectX Media Objects (DMO's, which the documentation encourages me to write instead of a filter) or to use a mixture of the two.

Will a filter allow me more complicated processing than simply blending two images, if I should need it? Do I need to worry about deadlocks and taking up too much processor time? If I want to re-encode the video once I've adjusted it, will it be easy to do that (considering I'm doubling the number of frames, will I be able to double the frame-rate as well?)

COM scares me a little :) I'm a final year Electrical Engineering and Computer Science student, and other than this project I don't have that much going on at the moment (Power Systems 4 and Computer Science 3, so I have plently of time to work on this tho, so I think I can at least get up and running with the COM part.

It's just that I need to show some preliminary work to my project leader ASAP, so I'm getting a little anxious now about getting started, and wasting time.

And if anyone can enlighten me as to if this is possible in C# I'd be most appreciative. Considering there doesn't seem to be much (any?) documentation for C# DirectShow, I probably won't go down this route, but I need to know if I have the option.

Thanks again for taking the time to read my long posts.

$£¥

Share this post


Link to post
Share on other sites
I don't know about DMOs (never worked with them), they seem to be nice to work with tho.
A filter will allow you to do any kind of processing you want but you should learn some assembly in order to see the filter working in real-time. You can recompress the video as you want after processing the video, but the output file size will be alot bigger because of the doubled frame rate.
COM isn't that hard, just read about it and/or create some kind of media player to be familiar with it.

btw, I can't help you with C#.

Goog luck and sorry for my English ;)

[edit]Graph example to recompress the video:
Source File->MPEG/AVI Demux->Video Decoder->YOUR FILTER->Video Encoder->MPEG/AVI Mux->File Output

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this