PDA

View Full Version : GetAudio() from GetFrame()


Ignus2
28th June 2007, 00:36
Is it possible to call GetAudio() from inside GetFrame()?
I want to draw things according to the audio of the clip (spectrum for example, etc.), but if I call GetAudio() from my GetFrame() method, the audio begins to stutter, then the whole thing crashes randomly.

Is it possible to draw things based on audio track?

Thanks in advance.

--
Greets,
I.

gzarkadas
28th June 2007, 02:20
IMHO your only option is to define appropriate data members in your filter that will be updated by GetAudio() and read their values in GetFrame() to make your drawing.

Note that this works when the video is played. If you are loading a script and switching to arbitrary frames by clicking on the frame selection scrollbar in editors like AvsP or VDub the variables are not updated (possibly because only GetFrame is called then).

IanB
28th June 2007, 06:57
Yes it is possible.

The stutering problem you describe has been fixed in 2.5.8 (bugs in audio cache).

Have a look at the CVS source of Histogram for some hints.

davidhorman
28th June 2007, 10:26
I've never had any problems with the Audgraph filter and AVS 2.5.7 (http://forum.doom9.org/showthread.php?s=&threadid=59412) which is presumably doing something similar to what you want to do?

David

Ignus2
28th June 2007, 11:19
I've never had any problems with the Audgraph filter and AVS 2.5.7 (http://forum.doom9.org/showthread.php?s=&threadid=59412) which is presumably doing something similar to what you want to do?

Well, it gives me this: AVIStreamSynth: System exception - Access Violation at 0x0, reading from 0x0
That's with 2.5.7

I'll be checking 2.5.8 now.

EDIT: It still doesn't work. I get random Acces Violations, crashes, I even got once "ACM reported error on audio decompress (0)".

What I'm actually doing is this:
- (start) calculate the starting sample number based on the video framerate, audio sample rate and the current frame in GetFrame()
- (count) calculate samples per frame according to framerate and audio sample rate
- call GetAudio() with above start and count parameters

--
Greets,
I.

Ignus2
28th June 2007, 12:17
Damn, this is weird indeed. It all works perfectly from VDub. But from Windows Media Player and Media Player Classic, it crashes or just produces that weird behaviour.
This is also the case for Histogram(mode="AudioLevels")

Any ideas why this might be?

ChiDragon
4th July 2007, 07:21
Do you also get the errors if you remove the graph filter and hit play (so that GetAudio is called)?

IanB
4th July 2007, 08:24
Does this script fail?ColorBars(Pixeltype="YV12")
Histogram(mode="AudioLevels")
# AudioDub(BlankClip(Last))Does it still fail if you uncomment the AudioDub line?

sh0dan
4th July 2007, 09:13
It is most likely a threading issue. DirectShow might very well request audio, while it is requesting a video-frame.

Therefore two threads are traversing the GetAudio path at the same time. There are two solutions. The easiest is to fill GetAudio requests with 0's. The other involves creating a lock, that blocks audio requests, when you yourself is requesting audio in your frame function.