Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th November 2021, 20:57   #1  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,904
GetChannels() wants a series of integers?

If I do something like:

Code:
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:

Code:
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:

Code:
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:

Code:
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...

Code:
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)

}

Last edited by FranceBB; 25th November 2021 at 21:29.
FranceBB is offline   Reply With Quote
Old 26th November 2021, 06:37   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
I just popped by before I went to bed [05:32], and have done little more than glance at less than half of your post,
but methinks that [4th code block]
Code:
GetChannels(clip1_channels_list)
is calling getchannels with a string, getChannels dont work with a string, so maybe something like
Code:
Eval ( "GetChannels(" + clip1_channels_list + ")"  )
Might work [assigns result to last - maybe you can get it to work by creating array from string, but I know nought bout that new fangled stuff].
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 26th November 2021 at 06:40.
StainlessS is offline   Reply With Quote
Old 26th November 2021, 10:54   #3  |  Link
VoodooFX
Banana User
 
VoodooFX's Avatar
 
Join Date: Sep 2008
Posts: 989
I dunno what GetChannels is, but your current mylist() could be replaced with something like this [how many channels there can be?]:

Code:
if (clip1_channels == 0) {
    audio1=GetChannels(my_clip1, 0)
} else if (clip1_channels == 1) {
    audio1=GetChannels(my_clip1, 1,1)
} else if (clip1_channels == 2) {
    audio1=GetChannels(my_clip1, 1,2,2)
} else if (clip1_channels == 3) {
    audio1=GetChannels(my_clip1, 1,2,3,3)
} else if (clip1_channels == 4) {
    audio1=GetChannels(my_clip1, 1,2,3,4,4)
} else if (clip1_channels == 5) {
    audio1=GetChannels(my_clip1, 1,2,3,4,5,5)
}

Last edited by VoodooFX; 26th November 2021 at 11:01.
VoodooFX is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 14:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.