DirectShow multi-video transition problem

Windows specific forum
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

DirectShow multi-video transition problem

Post by ozzie »

I'm using DirectShow in my PB program, using code based on that supplied by inc. and RASHAD, particularly Media Player [Windows]. That works fine, but if I want to cut to a second video while the first one is playing, I get a brief black image before the second video appears, even though there are no black frames at the start of the second video.

I've tried various ways to get a clean cut from the first video to the second video, but haven't found a way to achieve this. To demonstrate the problem I've put together a test program which you can download from https://dl.dropboxusercontent.com/u/63000633/DshowMediaTest.pb.

The test program is not very sophisticated but here's how to run it:
  • When you start the program you will be asked to "Choose media file 1", and you should select a video file and click 'Open'.
  • The program will then open a window to match the size of the video file you have selected. If you have a second screen connected then that window will be on the second screen. (I've only tested this with a second screen connected as that is how my program is intended to be used.)
  • You will then be asked to "Choose media file 2". Select another video file, preferably the same resolution (width and height) as the first video file. For this test you should be sure that there are no black frames at the start of this second video file.
  • You will then see the message 'Go when ready', so click OK to start playing the first video.
  • Now we come to the point of this test. Press the 'N' key on the keyboard to cut to the next video. The second video will start playing but there will be a brief black image shown before the video image itself appears. So my question is: how can I avoid having that brief black image displayed?
When the second video is opened (when you 'Choose media file 2') it is positioned off-screen to the left. When you press 'N' to cut to this next video, the program starts playing the second video, then immediately moves it to the visible display, and then frees the first video. I've tried adding delays between operations to try to see what causes the black, and it seems that the black occurs when the image is moved.

You will also see a test (currently 'If 1 = 1') which controls how the transition to the second video is implemented. If you change that to 'If 1 = 2' then the transition will slide the second video in from the left. This has an interesting and related result. As the video slides in from the left, this image of the second video is black until the slide is half-way, and then the image appears. The slide is also faster from that half-way point.

Any help on how to prevent this black between videos would be greatly appreciated!