DirectShow for BlitzMax

BlitzMax Forums/BlitzMax Tutorials/DirectShow for BlitzMax

time-killer-games(Posted 2014) [#1]
This doesn't fit in the tutorial subforum but everywhere else seems to be even less fitting. Feel free to move this wherever.

Play AVI, MP4, MPG and many other popular video formats in BlitzMax using the popular Win32 API known as DirectShow. Please note the end user MUST have any necessary codecs installed that your videos may be using!

This is an open source C++ DLL which can be called by BlitzMax for video playback. The zip includes the binaries, source, and example BMX project.

I haven't used BlitzMax for anything other than the MaxGUI stuff so you'll need to include the MaxGUI module, however, there may be a way to use this in a non-MaxGUI project if anyone wants to contribute such a feature.

Download: https://db.tt/ktzD9KOI



The code is pretty straight forward but if I get enough complaints I'll turn this into an official tutorial.

Thank you col! This wouldn't be possible without him. He doesn't want us to credit him (if I heard right, correct me if I'm wrong).

My dropbox is getting full so if anyone wants to upload mirrors of the screenshot and download they are more than welcome to do so and tell me about it (just in case).

Cheers.
Sam


col(Posted 2014) [#2]
Thank you col! ... He doesn't want us to credit him ...


Heh, that's cool. You did it anyway.

The only reason was that it wasn't any where near a complete dshow library, it just about scratches the surface of what's possible, but if it helps peeps then all is good :^)

BTW... In the code... you're not checking those 'hr' return values like you should, if something isn't right and you don't check them ( just use ' If hr < 0 ' and if its True then you have an error ) then it will give you at best unpredictable behavior and at worst a full on crash, more than likely the latter.

Have fun.


Hezkore(Posted 2015) [#3]
Cool stuff, but I can't seem to play any MP4 files?
Out of the 40 or so MP4 files I've tested, none has worked.


col(Posted 2015) [#4]
@Hezkore

I realise its older post but I just saw your message.

There are many ways to resolve the issue, and in true MS style - it can get complicated.

DirectShow has a mechanism called 'intelligent connect' that will scan your system for codecs and filters to use to create a graph, in this case a playback graph ( you can also create capture graphs too for capturing from anywhere! ). DShow filters and codecs are built with a 'priority of use' flag that the intelligent connect system also uses during graph construction. However I've seen several flaws in this system, one of which is that if intelligent connect finds a valid filter then it will use that filter in the graph and carry on building the graph further, but its almost as though it gets its knickers in a twist and doesn't try every combination of possible graphs that could be made and ultimately fails to build a correct playback graph. It doesn't mean that it can't play it, just that the intelligent connect system isn't intelligent enough! I've experienced this myself especially with mp4 playback.

Anyway the code above use the intelligent connection feature, but you can also build a graph manually in a couple of different ways: you can add instances of the filters yourself to the graph and then use the intelligent connect to connect them, and/or you could also connect the filters manually using specified media types. Its actually a very good system but its an incredibly steep learning ( for new comers to DShow ) with very lightweight documentation on how to do it scattered all over the internet. I've spent the last year learning this system. Once you get to grips with it then you realise that you can do absolutely anything related to audio/video media ( including receiving/creating live analog/digital/satellite broadcasts in any format for any language/country ), all you need are the filters and codecs to do what you need, and if they don't exist then you can create them yourself. Creating filters is an even steeper learning curve again, but not because the system is difficult but purely because of the lack of information available.

Getting to your issue of none of your videos playing back will undoubtedly be caused by the codecs used in the mp4 file and the intelligent connect system getting it wrong while trying to create a playback graph. So there's a couple of options, a fully customizable DirectShow system for Blitz products that are on Windows, or install more codecs on the hope that the intelligent connect will choose those filters, or maybe try to simply re-encode the mp4s to use a different codec so that the intelligent connect system doesn't get confused.

Windows Media Player uses the DirectShow system under the hood but I'm sure they don't use the intelligent connect feature and the coders of WMP have probably written their own version of intelligent connection handling.

Oh yeah, and don't forget who actually owns the rights to mp4 format and that we want to playback mp4s on a competitors OS, not that it should make any different but we all know how these OS creators 'play' at the top.