1

How to capture all frames (in RAM, not to disk) from TMediaPlayer (VCL) without showing the video on screen?


I tried this:

The MediaPlayer is set to show the movie in a panel:

MediaPlayer1.Display := pnlFakeScreen;
pnlFakeScreen.Visible:= true; 
pnlFakeScreen.top:= -10000; 

I use this to get the image from the invisible panel:

ADC := GetDC(pnlFakeScreen.Handle);
Bitblt(BMP.Canvas.Handle, 0,0,  BMP.Width, BMP.Height, ADC, 0, 0, SRCCOPY);

The capture does not work when the panel is invisible or out of screen.

Gabriel
  • 20,797
  • 27
  • 159
  • 293
  • That's most probably because MCI realized that it's not necessary to render on a window that is not visible. Why do you need to do this? – Victoria Aug 29 '17 at 17:07
  • Likely this is the wrong solution to your problem. Sadly you didn't state the problem. Classic XY scenario. – David Heffernan Aug 29 '17 at 17:11
  • @Victoria - I need to get the frames, do some processing on them and then display them (or save them to disk after processing). – Gabriel Aug 29 '17 at 17:13
  • Nope. That's your non solution. Your problem is more like that you want to extract stills from a video. – David Heffernan Aug 29 '17 at 17:13
  • The `TMediaPlayer` control just passes handle of the assigned `Display` control to the `MCI_WINDOW` command. The rest is controlled by MCI and it can easily determine whether the window is visible or not, and render according to the window state. Besides, how would you capture all the frames if you have no control over their changing (taking snaphots by timer is no good)? I would search for some DirectShow control instead. – Victoria Aug 29 '17 at 17:14
  • 3
    The MCI API does support capturing video frames directly without displaying them. `TMediaPlayer` simply does not expose that functionality, so use the API directly. – Remy Lebeau Aug 29 '17 at 17:59
  • 1
    Using DirectShow is probably the right solution, but beware: It's quite difficult to use, especially if you have never done any DirectShow programming before. You build a graph, add the filters you need, one of them must be a filter that allows capturing the pictures as bitmaps. We are using DSPack for this. https://sourceforge.net/projects/dspack/ – dummzeuch Aug 30 '17 at 07:57
  • @dummzeuch-I got a solution based on VFW (I know it is old) which UNTIL NOW works. If I encounter problems the next thing I will try is DSPack. Thanks. – Gabriel Aug 30 '17 at 12:27
  • PS: DSPack seems also quite outdated... – Gabriel Aug 30 '17 at 12:28

0 Answers0