Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
This simple Avisynth script converts an audio track from PAL to NTSC (or NTSC to PAL).
Required: nicaudio, to load audio files other than WAV
Optional: other audio import filters
Code: ################################################################################
# Avysinth script
#
# Converting audio tempo and/or pitch from PAL to NTSC and from NTSC to PAL
# note: NTSC works for both NTSC (29.97) and FILM (23.976) framerates
################################################################################
# choose ONLY one line and decomment it
# there are more audio loaders for avisynth,
# but these should cover 99% of restoration needs
################################################################################
# AC3 file load
#temp=nicac3source("filename.ac3")
# DTS file load
#temp=nicdtssource("filename.dts")
# WAV file load
#temp=wavsource("filename.wav")
################################################################################
# choose ONLY one line and decomment it
################################################################################
# change NTSC to PAL tempo, NOT pitch
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0))
# change NTSC to PAL tempo AND pitch too
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0),pitch=100.0*25.0/(24000.0/1001.0))
# changes PAL to NTSC tempo, NOT pitch
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000)
# change PAL to NTSC tempo AND pitch too
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000,pitch=(100.0*24000.0/1001.0)/25.000)
################################################################################
# create an empty video
vid=blankclip.loop
# mux video and audio together
audiodub(vid,aud)
# trim video to be long as audio
AudioTrim(0,last.AudioDuration)
# output is a WAV file
I'd like to see it as a function, with a call like soundconvert(audioclip,"p2n"yes) or something, where "p2n" is PAL to NTSC, and yes is for pitch conversion. Any good programmer here?
Posts: 1,747
Threads: 73
Joined: 2015 Mar
Thanks: 351
Given 313 thank(s) in 141 post(s)
Country:
(2016-11-13, 02:17 AM)spoRv Wrote: I'd like to see it as a function, with a call like soundconvert(audioclip,"p2n"yes) or something, where "p2n" is PAL to NTSC, and yes is for pitch conversion. Any good programmer here?
This may or may not work. I've never written anything in Avisynth before.
Code: #allowed file formats - ac3, wav, dts
#allowed commands - NTSC_TO_PAL_NO_PITCH, NTSC_TO_PAL_WITH_PITCH, PAL_TO_NTSC_NO_PITCH, PAL_TO_NTSC_WITH_PITCH
#filename must be full, with extension
function SoundConvert(string filename, string command)
{
extension = RightStr(filename, 3)
StrCmp(extension, "ac3") == 0 ? temp=nicac3source(filename) : NOP
StrCmp(extension, "dts") == 0 ? temp=nicdtssource(filename) : NOP
StrCmp(extension, "wav") == 0 ? temp=wavsource(filename) : NOP
################################################################################
StrCmp(command, "NTSC_TO_PAL_NO_PITCH") == 0 ? aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0)) : NOP
StrCmp(command, "NTSC_TO_PAL_WITH_PITCH") == 0 ? aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0),pitch=100.0*25.0/(24000.0/1001.0)) : NOP
StrCmp(command, "PAL_TO_NTSC_NO_PITCH") == 0 ? aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000) : NOP
StrCmp(command, "PAL_TO_NTSC_WITH_PITCH") == 0 ? aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000,pitch=(100.0*24000.0/1001.0)/25.000) : NOP
################################################################################
# create an empty video
vid=blankclip.loop
# mux video and audio together
audiodub(vid,aud)
# trim video to be long as audio
return AudioTrim(0,last.AudioDuration)
# output is a WAV file
}
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
WARNING! To anybody who had the script in their computer: there was an error in the "change PAL to NTSC tempo AND pitch" formula; now both posts #1 and #2 are corrected, so you should replace your script.
Posts: 491
Threads: 13
Joined: 2017 May
Thanks: 71
Given 248 thank(s) in 148 post(s)
Country:
I am far from all these scripts, but I know by experience that many programs even know how to drag the roads to other purity, but almost all of them do not retain the tone of voice and after distortion the voice is distorted, does your script also have a distortion?
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
No distorsion - but you must check if only tempo should be changed, or also pitch.
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
Updated script in the first post, adding 24fps... yes, I know, it's an easy add, but for the lazy ones (like me) it is nice to get everything ready!
And, yes, too lazy to make a simple function for it!
Code: ################################################################################
# Avysinth script
#
# Converting audio tempo and/or pitch from different sources
# note: NTSC works for both NTSC (29.97) and FILM (23.976) framerates
################################################################################
# choose ONLY one line and decomment it
# there are more audio loaders for avisynth,
# but these should cover 99% of restoration needs
################################################################################
# AC3 file load
#temp=nicac3source("filename.ac3")
# DTS file load
#temp=nicdtssource("filename.dts")
# WAV file load
#temp=wavsource("filename.wav")
# FF file load - should works with almost all other audio codecs
#temp=ffaudiosource("filename.putanaudioextensionhere")
################################################################################
# choose ONLY one line and decomment it
################################################################################
# changes NTSC to PAL tempo, NOT pitch
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0))
# changes NTSC to PAL tempo AND pitch too
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1001.0),pitch=100.0*25.0/(24000.0/1001.0))
# changes NTSC to 24fps tempo, NOT pitch
#aud=temp.TimeStretch(tempo=100.0*24.0/(24000.0/1001.0))
# changes NTSC to 24fps tempo AND pitch too
#aud=temp.TimeStretch(tempo=100.0*24.0/(24000.0/1001.0),pitch=100.0*25.0/(24000.0/1001.0))
# changes PAL to NTSC tempo, NOT pitch
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000)
# changes PAL to NTSC tempo AND pitch too
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/25.000,pitch=(100.0*24000.0/1001.0)/25.000)
# changes PAL to 24fps tempo, NOT pitch
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1000.0)/25.000)
# changes PAL to 24fps tempo AND pitch too
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1000.0)/25.000,pitch=(100.0*24000.0/1000.0)/25.000)
# changes 24fps to PAL tempo, NOT pitch
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1000.0))
# changes 24fps to PAL tempo AND pitch too
#aud=temp.TimeStretch(tempo=100.0*25.0/(24000.0/1000.0),pitch=100.0*25.0/(24000.0/1000.0))
# changes 24fps to NTSC tempo, NOT pitch
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/24.000)
# changes 24fps to NTSC tempo AND pitch too
#aud=temp.TimeStretch(tempo=(100.0*24000.0/1001.0)/24.000,pitch=(100.0*24000.0/1001.0)/24.000)
################################################################################
# create an empty video
vid=blankclip.loop
# mux video and audio together
audiodub(vid,aud)
# trim video to be long as audio
AudioTrim(0,last.AudioDuration)
# output is a WAV file
Posts: 1,554
Threads: 60
Joined: 2015 Jan
Thanks: 229
Given 627 thank(s) in 372 post(s)
Country:
2018-12-24, 03:38 PM
(This post was last modified: 2018-12-24, 03:38 PM by Chewtobacca.)
You can also perform these conversions with BeHappy, which uses AviSynth under the hood and enables you to preview the script so you can see how a given conversion is taking place.
Posts: 7,153
Threads: 601
Joined: 2015 Jan
Thanks: 1081
Given 1466 thank(s) in 963 post(s)
Country:
(2018-12-24, 03:38 PM)Chewtobacca Wrote: You can also perform these conversions with BeHappy, which uses AviSynth under the hood and enables you to preview the script so you can see how a given conversion is taking place.
Good! Well, for some old dinosaurs like me (and you ) the script could always be useful... maybe?
Posts: 1,554
Threads: 60
Joined: 2015 Jan
Thanks: 229
Given 627 thank(s) in 372 post(s)
Country:
2018-12-24, 09:31 PM
(This post was last modified: 2018-12-24, 09:32 PM by Chewtobacca.)
Yes; it's dinosaur friendly. If you're unsure, you can set up BeHappy, preview the script, and copy the relevant line into a project – a convenient safeguard against user error.
Posts: 1,111
Threads: 26
Joined: 2015 Jan
Thanks: 686
Given 305 thank(s) in 206 post(s)
2020-04-11, 05:45 PM
(This post was last modified: 2020-04-11, 05:48 PM by CSchmidlapp.)
Hi Guys I'm getting the following error.
Im running Avisynth+ 64bit Latest Version
I copied the code in the second post and saved it as soundconvert.avsi and put it into the plugins64+ in avisynth
Ive also added nicaudio
And trying to run the following script
Code: MPEG2Source("VTS_10_1.d2v").TFM(d2v="VTS_10_1.d2v").ColorMatrix(Source=2, dest=0).spline64resize(1024, 576).Assumefps(23.976)
LWLibavAudioSource("VTS_10_1 T81 2_0ch 192Kbps DELAY 0ms.ac3").SoundConvert("PAL_TO_NTSC_WITH_PITCH")
AudioDub(V,A)
FFT3Dgpu(sigma=1.5, plane=4, bt=4, mode=1, bw=16, bh=16, precision=2, ow=8, oh=8)
SR(1280, 720)
prefetch(8)
Im still learning AVIsynth so it's probably a problem with my script.
|