FranceBB
25th November 2021, 20:57
If I do something like:
ColorBars(848, 480, pixel_type="YV12")
GetChannels(1,2,2)
it works and gets me channel 1, 2, 2.
Now, if I declare this function:
function mylist(int n, string "s")
{
s = default(s, "")
return (n > 0) ? mylist(n - 1, String(n) + "," + s)
\ : s
}
and then I call it like this:
ColorBars(848, 480, pixel_type="YV12")
clip1_channels=(HasAudio) ? (AudioChannels) : 0
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
MessageClip(clip1_channels_list)
it returns 1,2,2
however if I try to use the variable I've just got with 1,2,2 inside GetChannels() it doesn't work:
ColorBars(848, 480, pixel_type="YV12")
clip1_channels=(HasAudio) ? (AudioChannels) : 0
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
GetChannels(clip1_channels_list)
Script error: Invalid arguments to function 'GetChannels'.
p.s the reason I brought this up is because I'm trying to write a function that takes two inputs, clip1 and clip2, uses the video from clip1 and the audio from clip1 and uses mergechannels to append the channels from clip2 to clip1. The user is gonna have two more parameters: InsertAt and DeleteCount. The first, InsertAt, allows the user to choose after which channel of the clip1 the audio from clip2 is inserted. DeleteCount instead allows the user to delete a certain channel he specifies from clip1.
I was writing the basics but the aforementioned issue came up...
function InsertExternalAudio(clip clp1, clip clp2) {
clip1_channels=(clp1.HasAudio) ? (clp1.AudioChannels) : 0
clip2_channels=(clp2.HasAudio) ? (clp2.AudioChannels) : 0
my_clip1=(clip1_channels>0) ? clp1.ResampleAudio(48000).ConvertAudioToFloat() : clp1
my_clip2=(clip2_channels>0) ? clp2.ResampleAudio(48000).ConvertAudioToFloat() : clp2
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
clip2_channels_list=mylist(clip2_channels) + String(clip2_channels)
audio1=GetChannels(my_clip1, clip1_channels_list)
audio2=GetChannels(my_clip2, clip2_channels_list)
video=clp1.KillAudio()
audio=MergeChannels(audio1, audio2)
AudioDub(video, audio)
}
ColorBars(848, 480, pixel_type="YV12")
GetChannels(1,2,2)
it works and gets me channel 1, 2, 2.
Now, if I declare this function:
function mylist(int n, string "s")
{
s = default(s, "")
return (n > 0) ? mylist(n - 1, String(n) + "," + s)
\ : s
}
and then I call it like this:
ColorBars(848, 480, pixel_type="YV12")
clip1_channels=(HasAudio) ? (AudioChannels) : 0
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
MessageClip(clip1_channels_list)
it returns 1,2,2
however if I try to use the variable I've just got with 1,2,2 inside GetChannels() it doesn't work:
ColorBars(848, 480, pixel_type="YV12")
clip1_channels=(HasAudio) ? (AudioChannels) : 0
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
GetChannels(clip1_channels_list)
Script error: Invalid arguments to function 'GetChannels'.
p.s the reason I brought this up is because I'm trying to write a function that takes two inputs, clip1 and clip2, uses the video from clip1 and the audio from clip1 and uses mergechannels to append the channels from clip2 to clip1. The user is gonna have two more parameters: InsertAt and DeleteCount. The first, InsertAt, allows the user to choose after which channel of the clip1 the audio from clip2 is inserted. DeleteCount instead allows the user to delete a certain channel he specifies from clip1.
I was writing the basics but the aforementioned issue came up...
function InsertExternalAudio(clip clp1, clip clp2) {
clip1_channels=(clp1.HasAudio) ? (clp1.AudioChannels) : 0
clip2_channels=(clp2.HasAudio) ? (clp2.AudioChannels) : 0
my_clip1=(clip1_channels>0) ? clp1.ResampleAudio(48000).ConvertAudioToFloat() : clp1
my_clip2=(clip2_channels>0) ? clp2.ResampleAudio(48000).ConvertAudioToFloat() : clp2
clip1_channels_list=mylist(clip1_channels) + String(clip1_channels)
clip2_channels_list=mylist(clip2_channels) + String(clip2_channels)
audio1=GetChannels(my_clip1, clip1_channels_list)
audio2=GetChannels(my_clip2, clip2_channels_list)
video=clp1.KillAudio()
audio=MergeChannels(audio1, audio2)
AudioDub(video, audio)
}