Jump to content
alank2

Playing an MP4 animation / unsupported media file / cppbuilder

Recommended Posts

I get an error when I try to use a MP4 for the TMediaPlayer.  Even the VideoPlayback sample will not work.

 

I did try to play an AVI and it doesn't error, but it doesn't play correctly either with a lot of visual artifacts.

 

Has anyone run into this before?

 

I found this:

https://stackoverflow.com/questions/64844414/register-new-media-codec-in-fmx-media-player-in-c-builder

But when I try to #include <FMX.Media.Win.hpp>, I get a ton of errors:

[bcc32c Error] Winapi.DirectShow9.hpp(237): use of undeclared identifier 'IDirectShowStream'

[bcc32c Error] Winapi.DirectShow9.hpp(491): no member named 'PReferenceTime' in namespace 'Winapi::Dxtypes'

...

 

Edited by alank2

Share this post


Link to post
39 minutes ago, alank2 said:

I get an error when I try to use a MP4 for the TMediaPlayer.

What is the actual error?  What version of C++Builder are you using, and what platform(s) are you attempting to play the MP4 on?

39 minutes ago, alank2 said:

Even the VideoPlayback sample will not work.

Did you verify the MP4 is valid to begin with?  Can you play it with other software players?

39 minutes ago, alank2 said:

I did try to play an AVI and it doesn't error, but it doesn't play correctly either with a lot of visual artifacts.

What kind of artifacts?

Share this post


Link to post

Hi Remy,

 

10.3, Windows 10

 

image.thumb.png.3c36048e8bf0993119fecef6873c76f1.png

 

It plays fine when double clicked and I also tried the Ocean.mp4 from the Embarcadero VideoPlayback sample.  I even tried compiling the sample.

 

The artifacts were when playing the AVI (the only file that would play), they looked like a failing video signal with part of the image updated, etc.  I could try another AVI to see if it plays properly, but I really want to get the MP4 playing if that is a possibility.

 

I tried what I saw you suggest in that stackoverflow post (#include <FMX.Media.Win.hpp>), but it fails with a ton of errors and won't compile if this header is included.

 

I appreciate the help!

Share this post


Link to post
On 8/11/2022 at 1:33 PM, alank2 said:

10.3, Windows 10

 

image.thumb.png.3c36048e8bf0993119fecef6873c76f1.png

That error happens if TMediaPlayer can't instantiate DirectShow's Graph Builder object (did you initialize the COM library beforehand?), or can't query the builder for the necessary video renderer interfaces, or the builder can't load the file to render it.

Edited by Remy Lebeau

Share this post


Link to post

Hi Remy,

 

>did you initialize the COM library beforehand?)

 

What do I need to do to do this?

 

image.thumb.png.ddba9b228c0019e79993b802b88d6045.png

Share this post


Link to post

I tried CoInitialize(NULL) and also CoInitializeEx(NULL, COINIT_MULTITHREADED) in FMXmain - same error.

 

Do I need to register the mp4 somehow?  I saw a mention of this, but it was in Delphi.

 

Share this post


Link to post
4 hours ago, alank2 said:

I tried CoInitialize(NULL) and also CoInitializeEx(NULL, COINIT_MULTITHREADED) in FMXmain - same error.

Did you make sure they were successful?  In any case, I'm not sure this IS the root cause, only that it is ONE POSSIBLE cause.  Like I mentioned, there are other reasons for that error to occur.  I suggest you enable Debug DCUs and step into the FMX source code with the debugger to see what is REALLY happening inside the TMediaPlayer.

4 hours ago, alank2 said:

Do I need to register the mp4 somehow?

Not that I'm aware of.  MP4 is one of the supported file extensions on Windows.  But that does not rule out the possibility that the MP4 file itself is bad in some way.

Share this post


Link to post

Thanks Remy - I'll see if I can figure out how to go the debug DCU route and see what I can find out.  I will also try a few other MP4's to make sure it isn't a certain one giving issues.

Share this post


Link to post

I created a Delphi project to try to dig into this.  Debug dcu's are on.

 

I trace it down to this function, but if I try to trace into it first must call the PChar and then with trace into it looks like it ends up in the windows message loop so I'm not sure how to find the RenderFile method to see what is going on there.

 

image.thumb.png.cc3b83e1e1d7b0fa82664e70afb84d14.png

 

Some more searching and I found Winapi.DirectShow9.pas which contains information about RenderFile

 

image.thumb.png.db88a426e436f559622ec896f000d1b7.png

 

I tried to set a breakpoint on it, but it doesn't stop.

 

Is there a way I can find out the HRESULT it is returning?  It looks like they are listed here:

https://docs.microsoft.com/en-us/windows/win32/api/strmif/nf-strmif-igraphbuilder-renderfile

 

Could AddSourceFilter have something to do with solving this?

Edited by alank2

Share this post


Link to post
26 minutes ago, alank2 said:

Is there a way I can find out the HRESULT it is returning?

I guess only by inspecting asm code and registers. Search for Succeeded's body (Status and HRESULT($80000000) = 0;) and see the register/memory cell it AND's with

Share this post


Link to post

Thanks - after failing and returning from the succeeded function, EAX is 80040265

 

https://www.remosoftware.com/info/how-to-fix-80040265-error-in-windows-media-player

 

I also found this page:

 

https://docwiki.embarcadero.com/Libraries/Alexandria/en/FMX.Media.TMediaCodecManager

 

It shows in windows that mp4 is a registered extension in the top table, but then below it only shows avi and wmv for windows video...

Share this post


Link to post

It may not be too late. The example does not work because of the missing codeck pack.

 

the solution:

https://stackoverflow.com/questions/28910428/tmediaplayer-error-unsupported-media-file

 

By Jim McKeeth

Quote

 

It appears to be a limitation of Direct X when installed in a VM. I installed a different media codec (the basic k-lite codec pack) and the player worked fine after that without any code changes. Also, filed a bug report so hopefully R&D can address it

 

the codeck.:

https://www.codecguide.com/download_kl.htm

 

Now all examples work fine.

..\Samples\Object Pascal\Multi-Device Samples\Device Sensors and Services\App Tethering\MediaPlayer\
and even the VideoPlayback sample works.

 

 

Share this post


Link to post

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

×