AudioVideoPlayback: swapping videos = black interval

  • Thread starter Thread starter D Cameron
  • Start date Start date
D

D Cameron

I'm using the (managed) Microsoft.DirectX.AudioVideoPlayback namespace
to program an app where I want to quickly swap the video that is being
displayed, playing the new video from the position where the old one
left off. Here's a sample of the relevant code:

// when this code is executed the current video
// is happily playing
current.Pause();
double pos = current.CurrentPosition;
current.Ending -= endHandler;

current = nextVideo; // next video has already been loaded
current.Ending += endHandler;
current.CurrentPosition = pos;
current.Owner = this.DisplayBox;
current.Play();

The problem is there is a brief black interval before the next video
starts playing. Because the interval is longer the further into the
video that the swap happens, I'm assuming that this has to do with the
codec getting the information ready. Problem is, I can't figure out any
way to force the codec to do this before I start playing, thereby
avoiding the black screen.

I've tried:
1- using Pause() or Play() before setting the Owner. Unfortunately this
opens a second display window.
2- Creating a second invisible PictureBox and assigning this as the
Owner. Then setting CurrentPosition and Pauseing. Then making it Visible
and Playing. The black interval still happens. Seems the Codec won't do
any decoding until it's actual got a surface to render to? (The video is
in DivX, processed with VirtualDub)
3 - Using SeekCurrentPosition(pos, IncrementalPositioning) instead of an
assignment to CurrentPosition. This didn't work at all, the video did
not play from the correct point.

Does anyone have any suggestions to try? Has anyone else solved this
problem?

Dave
 
I'm using the (managed) Microsoft.DirectX.AudioVideoPlayback namespace
to program an app where I want to quickly swap the video that is being
displayed, playing the new video from the position where the old one
left off. Here's a sample of the relevant code:

// when this code is executed the current video
// is happily playing
current.Pause();
double pos = current.CurrentPosition;
current.Ending -= endHandler;

current = nextVideo; // next video has already been loaded
current.Ending += endHandler;
current.CurrentPosition = pos;
current.Owner = this.DisplayBox;
current.Play();

The problem is there is a brief black interval before the next video
starts playing. Because the interval is longer the further into the
video that the swap happens, I'm assuming that this has to do with the
codec getting the information ready. Problem is, I can't figure out any
way to force the codec to do this before I start playing, thereby
avoiding the black screen.

The problem is the video renderer displaying a black frame before it has
any real video to show. I'm not aware of any good way around this, short
of writing your own video renderer in C++. (Which I did, partly to
overcome this problem.)
 
Thore said:
The problem is the video renderer displaying a black frame before it has
any real video to show. I'm not aware of any good way around this, short
of writing your own video renderer in C++. (Which I did, partly to
overcome this problem.)

I figured out a partial solution last night: reencoding the video with
many many keyframes (every 20 frames). Somehow, this actually made my
video files slightly smaller, and the black frame is almost completely
gone. There is some odd "stuttter" now during seeking, but overall it's
better.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top