alank2 5 Posted August 11, 2022 (edited) 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 August 11, 2022 by alank2 Share this post Link to post
Remy Lebeau 1413 Posted August 11, 2022 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
alank2 5 Posted August 11, 2022 Hi Remy, 10.3, Windows 10 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
Remy Lebeau 1413 Posted August 15, 2022 (edited) On 8/11/2022 at 1:33 PM, alank2 said: 10.3, Windows 10 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 August 15, 2022 by Remy Lebeau Share this post Link to post
alank2 5 Posted August 15, 2022 Hi Remy, >did you initialize the COM library beforehand?) What do I need to do to do this? Share this post Link to post
Remy Lebeau 1413 Posted August 15, 2022 1 hour ago, alank2 said: >did you initialize the COM library beforehand?) What do I need to do to do this? Make sure CoInitialize() or CoInitializeEx() is being called at program startup. Share this post Link to post
alank2 5 Posted August 15, 2022 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
Remy Lebeau 1413 Posted August 16, 2022 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
alank2 5 Posted August 16, 2022 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
alank2 5 Posted August 16, 2022 (edited) 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. Some more searching and I found Winapi.DirectShow9.pas which contains information about RenderFile 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 August 16, 2022 by alank2 Share this post Link to post
Fr0sT.Brutal 900 Posted August 16, 2022 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
alank2 5 Posted August 16, 2022 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
Remy Lebeau 1413 Posted August 16, 2022 4 hours ago, alank2 said: Thanks - after failing and returning from the succeeded function, EAX is 80040265 Related: Getting exception HRESULT: 0x80040265 with MP4 Files Share this post Link to post
skyzoframe[hun] 4 Posted October 11 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