Hi Simon,
>> 1) at what point in the code should I use GetBestSize() to determine
>> the size of my loaded video? And how can I then use that size to
>> adjust the player dimensions? As of right now I have the player set to
>> a proportion of the screen size, but this results in the video
>> stretching, so I want to be able to get the video size, make the video
>> as big as possible in the screen while maintaining the same aspect ratio
> Well, you need to do it after you know the file has been loaded and
> parsed. The MediaCtrl demo in the wxPython demos calls GetBestSize in a
> periodic timer, but that is probably a bit much. You should be able to
> resize your main window and have the sizers adjust your video frame
> accordingly, but it will be up to you to figure out the adjustments
> needed to keep the aspect ratio correct.
I always call it in the wx.EVT_SIZE events. IIRC, I call my Size event
once I know my media file is loaded.
>> 2) is there a way to get and store the current video frame (ie a
>> screenshot)?
> Not with the wx.media control. You can try using Blt from a DC to grab
> a copy of your window, but even that can be problematic. Depending on
> the capabilities of your graphics card, the video frames may not ever
> stored in the frame buffer. The frames are drawn into an offscreen
> overlay surface or texture surface, and the graphics card blends that
> surface in when it refreshes the screen.
I use FFmpeg for screen captures. It works okay, but was quite
difficult to get working on Windows and can be time-consuming as you get
further into the video file.
>> 3) is there a better way to implement the time slider? I have disabled
>> the slider because every time I use it the video lags as it tries to
>> reach that point in the video. Is there a smoother way to do it?
> The problem here is that a slider generates a LOT of events. You get an
> event when you start sliding, then continuous events while you drag the
> slider, then more events when you let go. As it is, you'll be pounding
> the player with seek requests, and arbitrary seek requests in modern
> video formats are expensive to handle. You might think about storing up
> the last slider value, and then checking in a timer to see if the
> desired seek point has changed since the last call.
Better than what? I've implemented a slider of my own that works with
from 1 to 4 simultaneous, synchronized media players. How well playback
works depends mostly on the characteristics of the media files
themselves. But if written correctly, the slider shouldn't interfere
with playback of a single media file. I'd look at what else could be
interfering with your playback speeds, say from events related to the
slider.
>> 4) is it possible to play a video backwards? or change its playback speed?
> There is a SetPlaybackRate API, but not all of the players support it.
> Playing an MPEG movie backwards, for example, is computationally
> intensive and not often supported.
The success of changing playback speed (when playing video forward)
varies heavily depending on the back end used and the media file
format. I've never tried playing video backwards outside of when users
are moving through a video file frame by frame manually, but I suppose
that calling lots and lots of seeks would work for some formats in some
back ends.
You're welcome to take a look at my source code at
http://sourceforge.net/projects/transana/ . Look particularly at the
video_player.py file, which implements a single instance of a media
player, and the VideoWindow.py file, which puts up to four video_players
into a window with a controller and a button for taking screen shots.
Also look at MediaConvert.py for the screen capture stuff.
David