Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AviSynth PAL <-> NTSC audio conversion
#1
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?
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by: PDB
#2
(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
}
Reply
Thanks given by:
#3
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.
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by:
#4
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?
Reply
Thanks given by:
#5
No distorsion - but you must check if only tempo should be changed, or also pitch.
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by:
#6
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! Wink
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
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by:
#7
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.
New members, please don't PM me for links to my projects until you have participated for a while and become active members of the forum. If I haven't posted updates in a thread, it's because there are none.
Reply
Thanks given by:
#8
(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 Wink ) the script could always be useful... maybe?
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by:
#9
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.
New members, please don't PM me for links to my projects until you have participated for a while and become active members of the forum. If I haven't posted updates in a thread, it's because there are none.
Reply
Thanks given by:


Possibly Related Threads...
Thread Author Replies Views Last Post
  eac3to The Audio Delay Thread Chewtobacca 16 4,712 2018-10-06, 01:47 AM
Last Post: Chewtobacca

Forum Jump:


Users browsing this thread: 1 Guest(s)