keyongtech


  keyongtech > win32.programmer.* > win32.programmer.directx.video > 03/2008

 #1  
03-04-08, 10:20 PM
Matan Gold
Hello everybody, I've got this problem that I've been working on for some
time now, and I'm about to despair...
I've written a C# application using DirectShowLib-2005 that previews audio
from the motherboard's Line In and video from my Video Capturing Device.

I'm using a vmr9 renderer for the video and the default renderer for the
audio. Here's what it looks like on GraphEdit :
[url down]

The problem is that the audio and video are out of sync (the audio is about
one second late).
How can I solve it ?

I've tried playing around with IReferenceClock and with
IAMBufferNegotiation, but nothing seems to work (but then again, maybe I
don't know how to use them). I'll be happy to add some code if it'll help.

Please, help me solve this issue...
 #2  
03-04-08, 11:46 PM
Alessandro Angeli
From: "Matan Gold"

> Hello everybody, I've got this problem that I've been
> working on for some time now, and I'm about to despair...
> I've written a C# application using DirectShowLib-2005
> that previews audio from the motherboard's Line In and
> video from my Video Capturing Device.


Somebody else might know better... but I don't think you can
keep the streams in sync, because they come from 2 separate
devices with different latencies in their hardware buffers
and driver stacks.

Let's say audio sample A corresponds to video sample V
according to their meaning, which only a human being can
know. At the device inputs, A and V will arrive at the same
time. But then A takes T[A] to go from the device input to
the graph, so A will have a timestamp TS[A] in the graph. V
instead takes T[V] and will be timestamped as TS[V] = TS[A]
+ T[V] - T[A]. Unless the devices talk to each so that T[V]
== T[A] (which is the case when the devices belong to the
same capture board), DirectShow will keep the streams in
sync according to their timestamps but those timestamps
assigned by the devices themselves will not keep the
original a/v sync.

There are a few interfaces the graph manager can use to
correct the situation, but they must be supported by the
drivers and/or custom capture filters, I don't think there
is nothing you can do (short of inserting a trans-in-place
filter, either custom or the stock SampleGrabber, and adjust
the timestamps according to sme higher knowledge coming from
outside the graph).
 #3  
03-05-08, 04:19 PM
Matan Gold
First, thank you for taking the time to answer.
At first, I did assume that maybe there's no way to synchronize two streams
from different capture devices, but now I'm sure that it's possible - both
Window Movie Maker and VLC display them in sync.

When I listen to the live preview done by Movie Maker \ VLC on my PC along
with the original TV source, I see that the previewed video is delayed so
it'll play along with the audio.

Does anyone know how to configure a buffer for video previewing ?
Thanks...
 #4  
03-05-08, 05:45 PM
Chris P.
On Tue, 4 Mar 2008 14:20:01 -0800, Matan Gold wrote:

> Hello everybody, I've got this problem that I've been working on for some
> time now, and I'm about to despair...
> I've written a C# application using DirectShowLib-2005 that previews audio
> from the motherboard's Line In and video from my Video Capturing Device.
>
> I'm using a vmr9 renderer for the video and the default renderer for the
> audio. Here's what it looks like on GraphEdit :
> [..]
>
> The problem is that the audio and video are out of sync (the audio is about
> one second late).
> How can I solve it ?
>
> I've tried playing around with IReferenceClock and with
> IAMBufferNegotiation, but nothing seems to work (but then again, maybe I
> don't know how to use them). I'll be happy to add some code if it'll help.


The biggest problem is the stock audio renderer. It requests large samples
of 0.5 seconds and has a 1 second internal buffer. Reduce the size of the
audio samples using IAMBufferNegotiation, and increase the number of video
samples. Hopefully then they will be able to start in sync. They may not
stay in sync permanently for the reasons pointed to by Alessandro.
 #5  
03-06-08, 12:03 AM
Matan Gold
> The biggest problem is the stock audio renderer. It requests large samples
> of 0.5 seconds and has a 1 second internal buffer. Reduce the size of the
> audio samples using IAMBufferNegotiation, and increase the number of video
> samples. Hopefully then they will be able to start in sync. They may not
> stay in sync permanently for the reasons pointed to by Alessandro.


Hi Chris,
How can I know which settings to set using IAMBufferNegotiation ?
Can you refer me to a relevant sample with IAMBufferNegotiation usage?
What does it mean to "increase the number of video samples" ?

Also, I think that the point reaised by Alessandro can be fixed using
"SetReferenceClock", can't it ?
Is there a problem setting all the Filters to a single IReferenceClock such
as BIOS ?
 #6  
03-06-08, 12:33 AM
Thore B. Karlsen [DShow MVP]
On Wed, 5 Mar 2008 16:03:00 -0800, Matan Gold
<MatanGold> wrote:

>> The biggest problem is the stock audio renderer. It requests large samples
>> of 0.5 seconds and has a 1 second internal buffer. Reduce the size of the
>> audio samples using IAMBufferNegotiation, and increase the number of video
>> samples. Hopefully then they will be able to start in sync. They may not
>> stay in sync permanently for the reasons pointed to by Alessandro.


>Hi Chris,
>How can I know which settings to set using IAMBufferNegotiation ?
>Can you refer me to a relevant sample with IAMBufferNegotiation usage?


Here you go:

http://sid6581.wordpress.com/2006/10...in-directshow/
 #7  
03-06-08, 05:34 PM
Matan Gold
I'll try it out, thank you.

"Thore B. Karlsen [DShow MVP]" wrote:
[..]
Similar Threads
Vista Media Center, using ATSC OTA and composite line in

Hi, I banged my head on this for a couple hours last night thinking I was missing something. I have a home built PC with Vista Media Center, and as of right now one...

Text box - No line on screen, but shows line when in preview/print

Thanks to Microsoft's terrific MVPs! I have a text box with a fill color of white and No line around it. On the screen it looks fine, but when in preview or when I printed...

synchronized or atomic scope may not nest any transactional or synchronized scopes

when i try to bulid my project of biztalk i have this bulid error in Error List << 'Transaction_2': a synchronized or atomic scope may not nest any transactional or...

working off-line/synchronized in a project

Hi, i´m working with Project2000. My projects consist of several subprojects, located partly on different drives on a server. Is there any prossibility to have a...

how to make a two line formatted (composite) style

hi, I am setting up a latex-like word style envoriment for my research writting. however, one problem puzzled me for weeks, I don't know any of you has good idea: in latex,...


All times are GMT. The time now is 12:46 PM. | Privacy Policy