AX-MediaPlayer - Cinder Block for Windows / macOS Video Playback

Given that I’m pulling out the rug from my own project, I’ll also see about exchanging WMFCinder for your framework @lithium . Can’t wait to try it!

I’m stuck representing the video path in the SimplePlaybackApp sample correctly. How do we set the CINDER_PATH macro? Ideally I’d like to load the video from the project’s assets folder, but I’m not able to set that path or load that asset for AX::Video::MediaPlayer either.

You’re not the first person to get caught by that, I thought i was being clever pointing the sample to the user’s cinder installation so I didn’t have to provide a test video, but apparently not ;). The CINDER_PATH macro gets injected by the sample’s cmake file, just for future reference.

But to your question, the constructor just takes a DataSourceRef so any usual cinder method of constructing those will work:

MediaPlayer::Create ( loadAsset ( "SomeAsset.mp4") ); // For a assets/SomeAsset.mp4 
MediaPlayer::Create ( loadFile ( "c:/Path/To/SomeFile.mp4") ); // For a fully qualified path
MediaPlayer::Create ( loadUrl ( "http://someserver.com/SomeStream.mp4") ); // For a streamed url  

I also got stuck in the cmake process, so I did not use it. I cloned your repo into the Cinder blocks folder, failed to get cmake to work, and then linked to the src directory instead. Perhaps this is why I am having so much difficulty.

Yeah cmake can be pretty annoying to get going but once it’s all set up it’s definitely better than the alternative. This thread has some good info about getting going on windows.

That said, this is a source only library and I handle all linking via #pragma comments so just dumping the source files into your project should be enough to get started. Did that not work either?

The linking seems to be working, but for good measure I’ve taken your advice and dumped the source files into the project.

I’ve put the video “bbb.mp4” into the assets folder of the project and added this file via VS Solutions Explorer. When I try to run (in setup()):

    auto fmt = AX::Video::MediaPlayer::Format().HardwareAccelerated(_hardwareAccelerated);

    _player = AX::Video::MediaPlayer::Create(loadAsset("bbb.mp4"), fmt);

I get the error:

1>TestAXMediaPlayerApp.obj : error LNK2019: unresolved external symbol "public: static class std::shared_ptr<class AX::Video::MediaPlayer> __cdecl AX::Video::MediaPlayer::Create(class std::shared_ptr<class cinder::DataSource> const &,struct AX::Video::MediaPlayer::Format const &)" (?Create@MediaPlayer@Video@AX@@SA?AV?$shared_ptr@VMediaPlayer@Video@AX@@@std@@AEBV?$shared_ptr@VDataSource@cinder@@@5@AEBUFormat@123@@Z) referenced in function "public: virtual void __cdecl TestAXMediaPlayerApp::setup(void)" (?setup@TestAXMediaPlayerApp@@UEAAXXZ)

Sorry, I need to straighten out my Cinder forum user accounts. Seems I have one account with autologin on my Mac from years ago and a more recent one on my PC.

It looks like you’re not compiling one (or more) of the source files. Do you want to put your project somewhere and I can have a look at it?

I do recommend getting cmake going at some stage though as all of these problems just magically go away, but for now, making a new test app in tinderbox and dragging all of the .h and .cxx files from the AX-MediaPlayer clone into the solution should be all you need to do.

for now, making a new test app in tinderbox and dragging all of the .h and .cxx files from the AX-MediaPlayer clone into the solution should be all you need to do

Ah, I thought that I did that, but I bet that while I did drag the AX-MediaPlayer source files to the project directories, I did not put them into the solution. I typically use xcode so VS also confounds me. I will push on using cmake.

Thank you!!

Hi @lithium this looks exciting, really looking forward to checking this out! A fresh new look at accessing video playback via the platform-provided WMF is great.

I’m curious how you usually run this - do you use cmake from the command line and generate a Visual Studio project, or open a specific folder in Visual Studio, ignore, etc? There are a number of approaches to go about configuring and building with cmake settings and I wanted to go with the way you’ve been using.

Cheers,
Rich

Hey mate, happy to hear it may come in handy for you. :slight_smile:

I tried to follow the existing cmake cinder block style so that you should be able to just add AX-MediaPlayer to the BLOCKS list when calling ci_make_app (assuming it lives in your {cinder_path}/blocks folder), or just selecting it as usual from TinderBox.

If all that fails, you can just dump the source files into your project, it’s laid out to potentially support other platforms / backends (i.e implemented via pimpl) but as it stands it’s just windows + wmf so every source file needs to be compiled, meaning just copying everything into your source tree should be fine.

Happy to take advice about this if there’s better ways to make itself available to a wider range of project formats though.

Thanks for putting it through its paces.

A

Got it working! With the command line I posted here for others who are trying to get the cmake build working.

Also tried out a 4K / 30fps video and it played very nicely at 60FPS on my PC.

Thanks again @lithium for putting this together! So far it looks like the best option for video on windows when you don’t want large dependencies, and I’ll try to put it through the wringer in upcoming projects.

For ease of other people testing, I’d suggest adding a Visual Studio project created from Tinderbox that plays nicely with the age-old way cinder is built on windows (although I do personally prefer cmake these days). I can send you a PR for this if it helps.

The other thing I’m looking at is if there is some format that WMF can play where we can have video with alpha channels, as this always comes up. I did see there is a H.265 / HEVC Video Decoder that should theoretically allow for this, but I recall using MF Transforms to be quite tricky.

It would be great to finally get a proper WMF video player in cinder core :wink: :wink: … the past attempts have fallen short but it is still the best native path.

@rich.e Curious what it is about the provided cmake config that prevented it from just working out of the box? I added the cinderblock.xml stuff as a convenience but it’s intended to be a “cmake first / source only” library so anything I can do to make that run more smoothly is always good.

With regard to alpha channels, it’s a requirement of both the software and hardware renderer paths that a BGRA surface/texture is used internally, so if we’re lucky, alpha channel video may be automatically supported if the appropriate codec is installed.

About cmake, I think I was just trying from the wrong folder to start. Worked once I remember how I originally organized things back in cmake rewrite days.

WRT alpha-enabled videos, I did a quick test with the only video I could find that allegedly has an alpha channel (attached on this page) and was sadly presented with a “file not supported” error. Yet, it does play in VLC so FFMPEG supports it - it may be a case of having to enable that MF Transform. Perhaps worth moving this to a github issue and seeing if others know more.

Do you have the HEVC extensions installed? Not ideal to have to install a codec like it’s the DivX days but it may get you out of a pinch where you control the target machine until we can figure out a more general solution.

Edit: I’ve created a ticket here with some relevant URLs for posterity so I’ve got a place to start when I get some time to look at this.

@rich.e I had an hour or two this afternoon to look at this, and while I was able to get HEVC video playing in general by just installing windows’ extensions, video with alpha will load but fails to process frames. My major concern is that since windows media player is also unable to play these files (I assume it’s using the same underlying media engine), so I wonder if VLC has their own HEVC implementation, or if there’s a way to coax media foundation into doing the right thing.

Documentation for this kind of stuff is almost nil, so i’ll keep poking around and see what shakes loose.

Ah, that’s a bummer that it doesn’t process at all. It doesn’t surprise me that Windows Media Player can’t do it since it predates this newer HEVC file format, though I was hoping that somehow there is a way Media Foundation still.

Here is a bit of info I found about ffmpeg’s current status with regards to video with alpha, which is not good either. Appears only apple’s decoder has handled this.

I’d be surprised if there wasn’t some way to do it, I was just hoping it may have been handled upstream by some smarter people :wink:

In my research it seems the state of video + alpha is basically a debacle across the board, I guess it’s been deemed a niche enough concern that no real effort has been made to address it at the codec level. I played around with VP9 but IMFMediaEngine seems to ignore the alpha channel altogether and just returns a solid black background which doesn’t bode well.

The real issue here is documentation and communication, the MF team have just ignored every question i’ve asked them so far and since updates are presumably bound to OS releases I don’t imagine they could be a particularly dynamic team with regard to shipping fixes / new features etc, so even getting a straight answer about if alpha is even supported at the library level is impossible.

Such is the tradeoff for relying on the native OS implementation of things, I guess. I’ll keep playing with this in my free time anyway, but hopefully it still can be a useful general purpose media toolkit, alpha channels notwithstanding.

A

Such is the tradeoff for relying on the native OS implementation of things, I guess. I’ll keep playing with this in my free time anyway, but hopefully it still can be a useful general purpose media toolkit, alpha channels notwithstanding.

I completely agree! That the outside dependencies other than what ships in Windows is why we always wanted to get a MF video impl into core, and also why we already use it for audio decoding / encoding. Here’s to hoping that with a bit more usage and testing we can move towards that. Video + alpha would be great but if it is still considered a niche feature, guess we still just have to look for other more annoyingly difficult solutions when that comes up. But who knows, perhaps someone will read this thread and know some way to make it happen that we don’t.

Cheers,
Rich

Just an FYI, i’ve added a macOS backend to my media player block that wraps cinder’s qtime::MovieSurface / qtime::MovieGl but with the API defined by the media foundation implementation, comes in handy for those of us who still jump around platforms a bit.

2 Likes