Re: Audio Running faster then Video
Re: Audio Running faster then Video
- Subject: Re: Audio Running faster then Video
- From: Jeff Moore <email@hidden>
- Date: Tue, 9 Aug 2005 15:53:55 -0700
On Aug 9, 2005, at 3:30 PM, Marc Van Olmen wrote:
<snip>
I can tell you that the for a movie with a duration of 2 hours 45
minutes. The Audio finishes about 0.933 seconds sooner then the
Video, this process happens gradually. I have the impression that
the Audio is on the CPU clock and not on the VideoCard clock? I
know for a fact that the Audio goes to the right output.
<snip>
Questions for finding a solution:
==================================
Question 1:
-----------
Is there a logical explanation for what I'm seeing.
Computers are nothing if not logical, deterministic, and obediant.
But that's the problem, they're always doing exactly what you tell
them...
Question 2:
-----------
Is it possible that coreAudio uses the CPU clock and not the Device
(in my case Aurora Video Card) clock?
Is it possible to check that? Or is there an option to change the
clock in coreAudio????
The HAL always tracks the hardware using the time stamps the hardware
provides. These time stamps track the mapping between the sample
clock and the CPU clock. This is fundamental in how OS X audio works
and cannot be changed.
Question 3:
-----------
Do I need to do my own synchronization?
You always need to do your own synchronization. The system provides
no magic. It is set up to provide as precise a description of what's
happening and when for each sub-system. It is up to the app, which is
the only participant with a view of all the things that need to be
synchronized, to do the right thing and supply the right data to each
sub-system at the proper time.
So sometime adding a few 0 samples or removing a few samples (just
incase....) to do my own synchronisation.
You'd be better off doubling a sample rather than adding a 0. This
provides less distortion and doesn't introduce the possibility of a
big pop being inserted due to the huge discontinuity.
But I need some guidance on how best approach this like which timer
I would use to synchronize the Video clock and Audio clock from the
parameters:
<snip>
I'm using I will need to use the mHostTime and I need to compare
that with the videoClock and in case the are too far off???? I need
to add a few 0 samples or distribute them over time so I don't hear
the difference....
Is that correct? I remember vaguely a discusion from Jeff Moore
about this
Basically, you need to be able to relate the native times of your
time lines to each other through the CPU clock. The HAL already does
this for you by supplying both the sample time and the host time in
each time stamp. This allows you to transform the time, X in samples,
into the time X' in CPU clock ticks. You need something similar with
the video clock. You need to be able to take the time Y in video
frames, and be able to transform it into Y' in CPU clock ticks. Once
you can do this transformation for all the time lines you need to
synchronize, you can then translate the native time of any single
time line into a time in some other time line.
This is how you figure out which audio frames go with which video
frames when you are rendering for playback. You just figure out what
CPU clock time is involved and then which frames fall into that
length of time.
--
Jeff Moore
Core Audio
Apple
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden