Log in

View Full Version : How to Resample 32kHz to 48kHz audio


bbiandov
9th August 2002, 09:37
Hello,

Can anyone post a script to Resample 32kHz 16bit to 48kHz 16bit audio. The function ResampleAudio(clip,new-sample-rate) causes error "ResampleAudio() does not exist" or something of that sort. I am sure I am missing somethign since the documentation does say audio filters exist and my expectation for this working is not so crazy.

thanks

DJ Bobo
9th August 2002, 10:16
Why would you do that? there won't be any quality improvement. The only reason would be to make it DVD compatible (=if you're making a DVD!). Here extract the audio from the video (use TMPG if it's a MPG, or NanDub or AVI2WAV if it's an AVI) and encode it to MP2 with 48KHz in TMPG. You can mux it later with the encoded video.

sh0dan
9th August 2002, 12:33
ResampleAudio([clip],samplerate) should work (just tested). Could I see your complete script file. What version of avisynth are you using?

bbiandov
10th August 2002, 02:20
sh0dan,

Thanks for the help. I use beta 6 and the entire script is 3 commands:

LoadPlugin("avisynthEx.dll")
IPCSource("untitled0")
ResampleAudio("untitled0",48000)

The LoadPlugin("avisynthEx.dll") is here because otherwise avisynth would not recognize IPCSource("untitled0") - this is explained in the readme so I followed it to the letter.

FYI: Yes I need to resample to make it DVD. No, TMPGenc resamling creates a sound file allright but sound quality is bad, it sounds like a barrel.. I would rather NOT do de-mux and then re-mux just so I resample the audio. It would be much more economical to do this on-the-fly just like people do all kinds of pull-down and other tasks on the fly during export to encoder. I think this is why avisynth exists in the first place.

bbiandov
10th August 2002, 17:49
Problem was solved. Working script is:

LoadPlugin("avisynthEx.dll")
IPCSource("untitled0")
ResampleAudio(48000)

wrong docs or incorrect syntax, go figure

sh0dan
11th August 2002, 15:26
Your syntax was wrong - and the documents are correct. ;)

What you actually did was passing a string instead of a clip. How variables and this stuff works:

clip1=avisource("file.avi")
clip_48=resampleaudio(clip1,48000)
return clip_48

All functions return a Clip, when they are used. Here clip1 is assigned the video from the AVI file. This clip is passed as argument to resampleaudio, and the result is assigned to variable clip_48.
If you don't assign the returned clip, it is used as the default clip, that automatically is assigned to the next clip. Here is a shorter version of the script above, that does exactly the same:

avisource("file.avi")
resampleaudio(48000)

Here is an example of what you can use vaiables for:

clip1=avisource("file.avi")
clip_48=resampleaudio(clip1,48000)
clipboth=alignedsplice(clip_48, clip1)
return clipboth

So you see, you can still use clip1, even though you modified it.

Read the docs and browse the forums.

bbiandov
22nd August 2002, 03:36
thanks sh0dan, that explained it all!

BB