Log in

View Full Version : write audio length from wave file


wiseant
6th September 2012, 02:59
Hi

I am trying to find a way to open a wave file using avisynth in order to write out the audiolength

For some reason it only seems to work if I use Directshowsource to open an av clip - then I can use WriteFile to write the audiolength

e.g.


a = Directshowsource("D:\MyMovie.avi")
b = a.audiolengthF
filename = "D:\wavsample.txt"
writefile(a,filename, "b")


but when I try to use either

a = Directshowsource("D:\MyWav.wav", video=false)
b = a.audiolengthF
filename = "D:\wavsample.txt"
writefile(a,filename, "b")


or


a = WavSource("D:\MyWav.wav")
b = a.audiolengthF
filename = "D:\wavsample.txt"
writefile(a,filename, "b")


I get a writefile error [avisynth2.58]

tebasuna51
6th September 2012, 10:47
1) Use writefileStart() instead writefile().
You only need one value, not the same value for each frame.
Using writefile() AviSynth try write a value for each video frame, and don't exist video frames with your last 2 avs.

2) How do you run the avs file?
Some soft, like Virtualdub, need a video stream and can show a error message.
Using writefileStart() Virtualdub show the error message but the D:\wavsample.txt is written correctly with the 3 avs.

The 3 work also using:
avs2avi D:\test.avs -o n -c null

StainlessS
6th September 2012, 11:37
should also work ok.

a = WavSource("D:\MyWav.wav")
b = a.audiolengthF
filename = "D:\wavsample.txt"
RT_TxtWriteFile(String(b),filename)
return colorbars()


EDIT: writefile would only be used if clip output from it is used by subsequent filter,
RT_TxtWriteFile will always be called irrespective of what follows.
Colorbars used, just to avoid throwing error when attempting to show return clip.

wiseant
6th September 2012, 19:14
Thanks guys - the text file gives me the info I want