View Full Version : CacheAudio
WarpEnterprises
14th December 2003, 23:17
As I realised recently using MPASource and ResampleAudio is useless slow.
The same happens with DirectShowSource (audio) and ResampleAudio.
The reason is that ResampleAudio request each frame in a manner that requires a little backward seeking.
Until now the video is cached by AviSynth, but not the audio.
So here is a filter that does this:
CacheAudio()
will cache 256kB of audio data (the memory size can be given as argument, too).
The filter is in the mpasource.dll, but you can use it after any audio source:
MPASource(blah).CacheAudio()
Look for download HERE (http://www.avisynth.org/warpenterprises)
Dark-Cracker
15th December 2003, 11:14
hi,
interesting filter :) i hope this will be merged and used automaticly in avisynth when i will add an audio entry in the .avs file :)
keep up the good work.
++
sh0dan
15th December 2003, 11:30
It will be! :)
I'm still considering the best implementation regarding memory usage, but WE's implementation seems ok, if it is only applied by filters that actually require the cache.
I would however rather have an implementation, that is able to automatically adjust the memory usage.
WarpEnterprises
15th December 2003, 13:24
For completeness: the current implementation
- checks if the current request is completely in the buffer
- if not decides if to restart or append the new data
- if the buffer is full, it "scrolls back" half its size (it seemed to me a good compromise between scrolling every time, making huge buffers or doing some kind of loop memory)
To dynamically adjust the USED (not the MAX) bytes sounds good and doable. I will try (something like a dynamic setpoint with a damping function)...
There is only a problem with the first request (I think it comes from ResampleAudio) which is often much bigger (the number of samples requested) than all subsequent requests.
sh0dan
15th December 2003, 14:03
I think your approach is the best. ResampleAudio were requesting the first samples with (start<0). The internal cache now automatically fills the invalid part of these types of request with silence. However SSRC is better in many ways.
Mug Funky
15th December 2003, 14:10
at the risk of going off on a tangent, what's the difference between what SSRC does and what ResampleAudio does?
i get lazy and just use resampleaudio for most things, but don't know the possible quality issues
sh0dan
15th December 2003, 14:55
Created a development thread here (http://forum.doom9.org/showthread.php?s=&threadid=66833). I hope you don't mind.
@Mug funky: Resampleaudio is quite good, but SSRC is perfect :) There is however still some quirks I need to work out on SSRC (like multiple instances).
ppera2
15th December 2003, 16:50
I recently made some conversions, and concluded that ResampleAudio is pretty buggy or whatever.
Directshowsource("G:\Att1.avi")
ResampleAudio(42294)
AssumeSampleRate(44100)
AssumeFps(25)
Yes, this works awfully slow, but even if I replace Directshowsource with WavSource (PCM), it produces very buggy sound. I noticed not only distorsion, but sometimes short repetations of sound, 1-2 sec later.
Btw. script is for speed up from 23.976 to 25 fps & resample audio from 48000 to 44100.
For now, only usable way is to prepare WAV with some sound editing program and avoid resample in AVISynth.
WarpEnterprises
16th December 2003, 21:17
it sounds exactly like the problems CacheAudio is intended for.
Maybe you can try it out.
Ookami
18th December 2003, 10:12
Hi.
Hope that all of you are all right!
A small addition...
There already exists a AviSynth plugin, or better to say a function in a plugin, with the same name from Minamina .
http://nullinfo.s21.xrea.com/
Wouldn't it be best to rename the plugin to avoid any possible confusion? In any way, thanks for the excellent work and a big hand waving to all of you!
ViewAudio.dll v0.3.01 Copyright(C) 2002, 2003 minamina
================================================================================
Avisynth Plugin - View Audio (YUY2 and YV12 Only)
- Description
audio display filter for Avisynth.
supports YUY2 and YV12.
supports Avisynth 2.5 only.
reference "AudioGraph()"(function of order frame phonological representation) by Richard Ling.
thanks, Richard Ling.
- Usage
LoadPlugin("ViewAudio.dll")
ViewAudio(clip, frames, top, height, fill, channel)
frames : after and before frame number. (default : 2)
top : y coordinates of starting point. (-1 means "drawing blow the clip", default : -1)
height : hight of drawing. (default : 80)
fill : smears away the drawing area. (default : true)
channel : audio channel to draw. (-1 means "draw all channels", default : -1)
- Example
ViewAudio()
ViewAudio(1, 0)
ViewAudio(height = 200)
================================================================================
Avisynth Plugin - Cache Audio
- Description
Audio cache filter for Avisynth.
supports Avisynth 2.5 only.
use as assistance when editing AudioSource() that is poor at rabdom access.
- Usage
LoadPlugin("ViewAudio.dll")
CacheAudio(clip, MaxFrame, BlockFrame)
MaxFrame - maximum frame size. (default : 1000)
-1 : get all frames. (requires large memory area. it takes time a first time display.)
BlockFrame - number of frames read at once. (default : 100)
-1 : use same value of "MaxFrame". (requires large memory area. it takes time a first time display.)
- Example
CacheAudio()
CacheAudio(10000, 300)
CacheAudio(MaxFrame = 20000)
================================================================================
- History
2003/11/03 v0.3.01 add function CacheAudio().
2003/10/06 v0.2.02 fixed the problem of when checking maximum frame number.
2003/09/22 v0.2.01 add function to draw before and after frame of the audio.
2003/03/16 v0.1.01 supports Avisynth 2.5.
supports YV12.
2002/12/15 v0.0.01 first release.
Cheers,
Mijo
Wilbert
18th December 2003, 13:07
@ppera2,
Did WarpEnterprises suggestion solved your problems?
ppera2
18th December 2003, 15:36
Originally posted by WarpEnterprises
it sounds exactly like the problems CacheAudio is intended for.
Maybe you can try it out.
I tried it. Distorsion is much-much lower. However, I'm still not satisfied with sound quality. It looks that other solutions offer better quality of resample. Will try again with different source...
Is it normal that by MPA source I have delay of about 1 minute when jump from beginning to 1h 40 min? As I see increasing cache size doesn't changes that delay significantly.
WarpEnterprises
19th December 2003, 08:08
MPASource: thats normal. there is no index of an mpg file so I scan the whole file until the desired position is reached to be strictly sample-accurate.
[EDIT] CacheAudio will be renamed to BufferAudio.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.