View Full Version : Audio related Problems, 2.58/2.6
StainlessS
6th September 2011, 21:50
Audio related Problems, 2.58/2.6
EDIT: Any references to an Audio Lag, should read Audio Lead or Video Lag.
I was having a problem of the occasional crash using a demo script
with the new Prune Trim & Splice plugin:
http://forum.doom9.org/showthread.php?t=162446
There seemed to be an audio time lag in splicing trims together,
(sometimes, not all the time) especially in Media Player Classic.
I did not think the problem lay with Prune, and so I stripped out
the Prune related stuff and replaced with standard trim and
splices. The script still resulted in strange behaviour, sometimes
stuttering, sometimes audio beating, sometimes crashes
(CAVIStream [or whatever it's called]). The test version was
Avisynth 2.58 and suspecting version related, I switched to
v2.6 and although the crashes seem to have stopped, it still
displays strange behaviour, stuttering and sometimes beating (audio), in
Media Player Classic and any of three different versions of VirtualDub (plain, MPEG2, & VirtualDubMod).
I'm wondering, is this audio problem cache related, Tone related and/or
AudioGraph related.
Here is the script:
R0=ColorBars()
R3=R0.FlipHorizontal().FlipVertical().AudioDub(Tone(3600.0,550.0,level=0.5)).Trim(0,9999)
R2=R0.FlipVertical().AudioDub(Tone(3600.0,440.0,level=0.5)).Trim(0,9999)
R1=R0.FlipHorizontal().AudioDub(Tone(3600.0,330.0,level=0.5)).Trim(0,9999)
R0=R0.AudioDub(Tone(3600.0,220.0,level=0.5)).Trim(0,9999)
R0=R0.ScriptClip("""subtitle(Align=5,size=64,"R0("+string(current_frame)+")")""")
R1=R1.ScriptClip("""subtitle(Align=5,size=64,"R1("+string(current_frame)+")")""")
R2=R2.ScriptClip("""subtitle(Align=5,size=64,"R2("+string(current_frame)+")")""")
R3=R3.ScriptClip("""subtitle(Align=5,size=64,"R3("+string(current_frame)+")")""")
A=R0.Trim(77,-100)
B=R1.Trim(34,-200)
C=R2.Trim(150,-300)
D=R3.Trim(66,-800)
E=R0.Trim(100,200)
F=R1.Trim(250,500)
G=R2.Trim(160,260)
H=R3.Trim(256,356)
I=R0.Trim(400,600)
J=R1.Trim(500,700)
K=R2.Trim(0 ,300)
L=R3.Trim(9000,0)
Z=A++B++C++D++E++F++G++H++I++J++K++L
Z
AudioGraph(1) # can comment out
return Last
EDIT:
The AudioGraph bit can cause problems in both 2.58 & 2.6,
and without the Audiograph, is still troublesome in 2.58.
In Media Player classic, with 2.6, you may have an audio lag
in switching between trims, Or stuttering in VD.
EDIT: Damn, now I'm seeing video lag rather than audio.
StainlessS
6th September 2011, 22:48
With this script, just replaced ColorBars with live video and the audio/video is perfectly
in sync, (however, a strange 3 phase effect in AudioGraph on clip R3 [for me,
EDIT: 3 sinusoidal waves displaced by 180 degrees from each other]).
R0=Avisource("D:\avs\avi\1a.avi").ConvertToYUY2()
R3=R0.Trim(40000,-10000).AudioDub(Tone(3600.0,550.0,level=0.5)).Trim(0,0)
R2=R0.Trim(30000,-10000).AudioDub(Tone(3600.0,440.0,level=0.5)).Trim(0,0)
R1=R0.Trim(20000,-10000).AudioDub(Tone(3600.0,330.0,level=0.5)).Trim(0,0)
R0=R0.Trim(10000,-10000).AudioDub(Tone(3600.0,220.0,level=0.5)).Trim(0,0)
R0=R0.ScriptClip("""subtitle(Align=5,size=64,"R0("+string(current_frame)+")")""")
R1=R1.ScriptClip("""subtitle(Align=5,size=64,"R1("+string(current_frame)+")")""")
R2=R2.ScriptClip("""subtitle(Align=5,size=64,"R2("+string(current_frame)+")")""")
R3=R3.ScriptClip("""subtitle(Align=5,size=64,"R3("+string(current_frame)+")")""")
A=R0.Trim(77,-100)
B=R1.Trim(34,-200)
C=R2.Trim(150,-300)
D=R3.Trim(66,-800)
E=R0.Trim(100,200)
F=R1.Trim(250,500)
G=R2.Trim(160,260)
H=R3.Trim(256,356)
I=R0.Trim(400,600)
J=R1.Trim(500,700)
K=R2.Trim(0 ,300)
L=R3.Trim(9000,0)
Z=A++B++C++D++E++F++G++H++I++J++K++L
Z
AudioGraph(1)
return Last
IanB
6th September 2011, 23:26
I believe this was the fix for the 2.58 crash as found by Gavino.
Due to the 4 scriptclips of subtitles I don't have a beast fast enough to reliably realtime this script, but a rendered version plays just fine for me and randomly jumping around to check the transitions displays by AudioGraph() are always correct so far.
I have a vague recollection of versions of AudioGraph originally being borked in some way. I have 2 versions dated 29/11/04 and 5/11/07 in my archives but I appear to have lost their provenance over the years, so where I got them is now a mystery.
----------------------------
revision 1.33
date: 2009/09/26 08:05:53; author: ianb1957; state: Exp; lines: +15 -16
2.6 import + /W4 + Bugfix AudioCache snafu (Gavino)
----------------------------
diff -r1.32 -r1.33 cache.cpp
***************
*** 665,683 ****
else {
if (start+count > cache_start+cache_count) { // Does the cache fail to cover the request?
if (start+count > cache_start+maxsamplecount) { // Is cache shifting necessary?
! shiftsamples = (start+count) - (cache_start+maxsamplecount);
if ( (start - cache_start)/2 > shiftsamples ) { //shift half cache if possible
! shiftsamples = (start - cache_start)/2;
}
! if (shiftsamples >= cache_count) {
! shiftsamples = cache_count; // Preserve linear access
}
else {
! memmove(cache, cache+shiftsamples*samplesize,(cache_count-shiftsamples)*samplesize);
}
- cache_start = cache_start + shiftsamples;
- cache_count = cache_count - shiftsamples;
}
// Read just enough to complete the current request, append it to the cache
child->GetAudio(cache + cache_count*samplesize, cache_start + cache_count, start+count-(cache_start+cache_count), env);
--- 663,682 ----
else {
if (start+count > cache_start+cache_count) { // Does the cache fail to cover the request?
if (start+count > cache_start+maxsamplecount) { // Is cache shifting necessary?
! int shiftsamples = (int)((start+count) - (cache_start+maxsamplecount)); // Align end of cache with end of request
if ( (start - cache_start)/2 > shiftsamples ) { //shift half cache if possible
! shiftsamples = (int)((start - cache_start)/2);
}
! if (shiftsamples >= cache_count) { // Can we save any existing data
! cache_start = start+count - maxsamplecount; // Maximise linear access
! cache_count = 0;
}
else {
! memmove(cache, cache+shiftsamples*samplesize, (size_t)((cache_count-shiftsamples)*samplesize));
! cache_start = cache_start + shiftsamples;
! cache_count = cache_count - shiftsamples;
}
}
// Read just enough to complete the current request, append it to the cache
child->GetAudio(cache + cache_count*samplesize, cache_start + cache_count, start+count-(cache_start+cache_count), env);
***************
Gavino
6th September 2011, 23:35
There was an audio cache bug causing random crashes in v2.58, fixed in 2.60 (it also worked in 2.57).
(Edit: this is the one mentioned by IanB above.)
AudioGraph was known to be prone to crashing but I believe the underlying cause was fixed in v2.58.
StainlessS
7th September 2011, 02:34
Whoops, please ignore what I said about audio lags, think it was audio lead all the time.
(I'm sooo easily confused by complicated stuff). :stupid:
@IanB & Gavino, thankyou for both of your answers, I found a reference to a bug fix
in the changelog for 2.6, "Fixed Audio cache crashes.", assumed that it was related to
this. However, I have been doing a little bit of testing, and made a few notes.
(am falling asleep as I write this so I'll have to do it quick).
V2.58 1st SCRIPT TEST
VirtualDubMod Plain 1.9.11
AudioGraph OFF
Stuttering, In sync.
AudioGraph ON
Avisynth read error: CAVIStreamSynth: System exception - Access Violation at
0x1de9aca, 0x30de000
---------------------------
VirtualDubMod
AudioGraph OFF
In sync. Audio Beating.
AudioGraph ON
Avisynth read error: CAVIStreamSynth: System exception - Access Violation at
0x1209aca, writing to 0x462f000
Also @ 0x117510a, 0x917b000
Faulting application virtualdubmod.exe, version 1.5.10.3,
faulting module ntdll.dll, version 5.1.2600.6055, fault address 0x0001240b.
---------------------------
MediaPlayerClassic 1.4.2677.0
AudioGraph OFF
Audio terminated slightly before video. (This time)
AudioGraph ON
Audio leading video, progresssively greater through the clip.
(Audio terminated about 9 secs before video).
---------------------------
GOM Player 2.1.28.5039
AudioGraph OFF
Audio Leads Video by a second or more.
AudioGraph ON
Audio leading video, progresssively greater through the clip.
On clicking on the timeline I got a brief message, something about
a System Evaluation Exception in Scriptclip.
Repeated, got a, Avisynth read error: CAVIStreamSynth: System exception - Access Violation at etc.
V2.6 1st SCRIPT TEST
VirtualDubMod Plain 1.9.11
AudioGraph OFF
Stuttering, In sync.
AudioGraph ON
Bad Stuttering, every two or so secs, in Sync.
---------------------------
VirtualDubMod
AudioGraph OFF
Slight stutter at start. Audio Beating near start, (2nd run OK).
AudioGraph ON
Slight stutter at start.
Avisynth read error: CAVIStreamSynth: System exception - Access Violation at
0x117510a, 0x9c2b000 (Same as VDMod in 2.58, maybe AudioGraph OR VDMod).
0x117510a, 0x976b000
---------------------------
MediaPlayerClassic 1.4.2677.0
AudioGraph OFF
OK
AudioGraph ON
Audio leading video, progresssively greater through the clip.
(Audio terminated about 10 secs before video).
Click on time line, CAVIStreamSynth: System exception - Access Violation at
0x7c910f1e, 0xbefaf30d
---------------------------
GOM Player 2.1.28.5039
AudioGraph OFF
Audio Leads Video by a about 4 secs.
AudioGraph ON
Audio leading video, progresssively greater through the clip.
(Audio terminated about 10 secs before video).
Click on time line, CAVIStreamSynth: System exception - Access Violation at
0x7c910f1e, 0xbefaf30d
v2.6, 2nd SCRIPT TEST with LIVE VIDEO at 25FPS VIDEO
MediaPlayerClassic 1.4.2677.0
AudioGraph OFF
OK
AudioGraph ON
OK
Click on time line, CAVIStreamSynth: System exception - Access Violation at
0x238510a, 0x990a000
The crashing seems to be fully related to AudioGraph.
And taking what IanB said, "I don't have a beast fast enough to reliably realtime this script", then perhaps I dont either, and
that is the source of the stuttering and perhaps audio beat-ing.
It may also be the reason that the 25 FPS (less work) test with 2nd script
is in good sync, I was thinking that the issue
was maybe related to NTSC FPS of ColorBars and Trim/Spice and Tone(), but having a feeble machine is probably the real
explaination.
Thanks guys for your time :thanks:
EDIT: the ver$ AudioGraph that I have is 2004, so it is probably a naff one.
Will fix it tomorrow, gorra get some sleep, thankyou & goodnight.
Gavino
7th September 2011, 10:49
And taking what IanB said, "I don't have a beast fast enough to reliably realtime this script", then perhaps I dont either, and that is the source of the stuttering and perhaps audio beat-ing.
I can't run your ColorBars script in real time either - video lags progressively behind audio, but without crashing, using latest v2.60 and MPC 6.4.9.1.
Removing ScriptClip and just using Subtitle (no frame numbers) gives audio perfectly in sync - no problems jumping around timeline either. (Subtitle inside ScriptClip is slow since bitmap must be regenerated for each frame - similarly applies to ShowFrameNumber et al.)
No problems with AudioGraph (dated 18/3/2004) using v2.60.
StainlessS
7th September 2011, 15:08
I can't run your ColorBars script in real time either - video lags progressively behind audio, but without crashing, using latest v2.60 and MPC 6.4.9.1.
When I used the term MediaPlayerClassic I was referring to this program:-
http://mpc-hc.sourceforge.net/
Not Media Player 2, v6.4.9.1126 (which I have, on XP @
C:\Program Files\Windows Media Player\MPlayer2.Exe).
MPC (Home Cinema) is quite good, many built in codecs and will play quite
highly compressed x264-MP4 on my old ropey Pentium 3
m/c whereas GOM and VLC have problems with such.
There was a new version issued in July 2011, as in above link.
Am upgrading to that one. I think I read somewhere that MPC
is written almost exclusively in assembler hence the better
handling of highly compressed clips on less powerfull m/c's.
EDIT: Wrong on that, written in C++.
I will probably mod the script to Assume 18FPS or something
like that and give a reason in the script.
Thanks again.
StainlessS
7th September 2011, 18:10
I have a vague recollection of versions of AudioGraph originally being borked in some way. I have 2 versions dated 29/11/04 and 5/11/07 in my archives but I appear to have lost their provenance over the years, so where I got them is now a mystery.
The version AudioGraph I have is zip dated 18 Mar 2004
(the one on WarpEnterprises is 8 Aug 2003), could not find
either of the dated ones you mentioned, I did however
find source, on SourceForge with this in ConvertAudio.cpp
// ConvertAudio classes
// Copyright (c) Klaus Post 2001 - 2004
// Copyright (c) Ian Brabham 2005
with the internal source files dates 20 sept 2008.
http://audiograph.svn.sourceforge.net/viewvc/audiograph/
EDIT: Just realized that the ConvertAudio.cpp file is from the Avisynth
2.58 source. Wonder if there is a compiled version of v2.58 together
with the audio cache bug fixed, (apart from an MT version, which I
do not want to use).
I presume this is a later offering than the one you are using, I
shall compile and add as attachment to this thread.
Midzuki
7th September 2011, 19:22
Surely I am asking for too much :o , but... how about developing a brand-new Audiograph() which would use the "well-known" BASS.dll ???
http://forum.doom9.org/showthread.php?p=1362425#post1362425
StainlessS
7th September 2011, 21:24
Surely I am asking for too much :o , but... how about developing a brand-new Audiograph() which would use the "well-known" BASS.dll ???
http://forum.doom9.org/showthread.php?p=1362425#post1362425
Well if that was aimed at me, not sure I'd want to touch audio
any further. I only spend a few hours converting the ClipClop
range editing source to Prune, trim & splice, when it occurred
to me that I needed to also cope with audio, I nearly abandoned
the idea altogether, purely because of that. It would be better
to accost someone with more experience of audio in Avisynth,
I was only stumbling around in the dark, when I got it working.
Good luck. :)
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.