kdtong
kdtong

Reputation: 184

Delay in video in DirectShow graph

I'm seeing a noticeable video which is causing the resulting audio/video sync to be off for a capture card that I'm testing. My graph topology is as follows.

Video Source -> Sample Grabber -> Null Renderer

Audio Source -> Sample Grabber -> Null Renderer

The samples from video is compressed using H264, and Audio is compressed using FAAC. This topology and application code works for capture cards that I've used in the past. But I see this delay with the current card that I'm testing. Naturally I thought it was related to the card itself. So I checked and found that there is no video/audio desync when using Open Broadcaster, VLC, or the same graph in GraphEdit to capture with this card.

This indicates to me that the problem is related to how I'm constructing the graph. I then tried adjusting the buffer sizes using IAMBufferNegotiation, as well as SetStreamSyncOffset without success.

The sync is almost perfect if I apply a 500 ms lag to the video (e.g. videoTimeStamp = videoTimeStamp - 500). This is strange because I would expect to see more latency in the audio than video.

Upvotes: 1

Views: 1381

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69662

Video and audio synchronization is all about time stamps. Video or audio leg might delay processing of data, but it is time stamps that show original and intended sync.

Potential causes include:

  1. Video and audio sources timestamp data independently, incorrectly delivering unsynchronized data - does not look like your case
  2. You neglect time stamps and you use actual time of sample arrival to your sample grabber, which is incorrect
  3. Another filter in between, such as decoder, incorrectly restamps data when processes it

Upvotes: 2

Related Questions