Hi there, Peter and welcome to the forum.
First of all, one of the things to keep in mind is that to use the StackHorizontal() and StackVertical() you need the clips to have the very same resolution, the very same framerate, the very same color space and the very same bit depth, so it could be a bit tricky to use those commands on different clips without knowing what they are.
What I came up with are two functions called StackMeHorizontal() and StackMeVertical() that take care of those things for you and that you can use to Stack two files with different characteristics horizontally or vertically:
Code: Select all
function StackMeHorizontal(clip clp, clip clp2) {
x=Width(clp)
y=Height(clp)
pp1=Spline64Resize(clp2, x, y)
fps=FrameRate(clp)
pp2=ConvertFPS(pp1, fps)
Bpc = BitsPerComponent(clp2)
MyColorSpace = clp.IsY ? "Y" : clp.IsY8 ? "Y8" : clp.IsYV12 ? "YV12" : clp.IsYUY2 ? "YUY2"
\ : clp.IsYV16 ? "YV16" : clp.IsYV24 ? "YV24"
\ : clp.Is420 ? "YUV420" : clp.IsYV411 ? "YUV411" : clp.Is422 ? "YUV422" : clp.Is444 ? "YUV444"
\ : ""
MyColorSpace == "Y8" ? ConverttoY8(pp2)
\ : MyColorSpace == "YUV411" ? ConverttoYUV411(pp2)
\ : MyColorSpace == "YV12" ? ConverttoYV12(pp2)
\ : MyColorSpace == "YV16" ? ConverttoYV16(pp2)
\ : MyColorSpace == "YUY2" ? ConverttoYUY2(pp2)
\ : MyColorSpace == "YV24" ? Converttoyv24(pp2)
\ : MyColorSpace == "Y" && Bpc == 10 ? ConverttoY(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV420" && Bpc == 10 ? ConverttoYUV420(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV411" && Bpc == 10 ? ConverttoYUV411(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV422" && Bpc == 10 ? ConverttoYUV422(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV444" && Bpc == 10 ? ConverttoYUV444(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "Y" && Bpc == 12 ? ConverttoY(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV420" && Bpc == 12 ? ConverttoYUV420(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV411" && Bpc == 12 ? ConverttoYUV411(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV422" && Bpc == 12 ? ConverttoYUV422(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV444" && Bpc == 12 ? ConverttoYUV444(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "Y" && Bpc == 14 ? ConverttoY(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV420" && Bpc == 14 ? ConverttoYUV420(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV411" && Bpc == 14 ? ConverttoYUV411(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV422" && Bpc == 14 ? ConverttoYUV422(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV444" && Bpc == 14 ? ConverttoYUV444(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "Y" && Bpc == 16 ? ConverttoY(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV420" && Bpc == 16 ? ConverttoYUV420(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV411" && Bpc == 16 ? ConverttoYUV411(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV422" && Bpc == 16 ? ConverttoYUV422(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV444" && Bpc == 16 ? ConverttoYUV444(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "Y" && Bpc == 32 ? ConverttoY(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV420" && Bpc == 32 ? ConverttoYUV420(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV411" && Bpc == 32 ? ConverttoYUV411(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV422" && Bpc == 32 ? ConverttoYUV422(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV444" && Bpc == 32 ? ConverttoYUV444(pp2).ConvertBits(bits=32)
\: ""
my_second_clip=last
my_first_clip=clp
StackHorizontal(my_first_clip, my_second_clip)
}
and
Code: Select all
function StackMeVertical(clip clp, clip clp2) {
x=Width(clp)
y=Height(clp)
pp1=Spline64Resize(clp2, x, y)
fps=FrameRate(clp)
pp2=ConvertFPS(pp1, fps)
Bpc = BitsPerComponent(clp2)
MyColorSpace = clp.IsY ? "Y" : clp.IsY8 ? "Y8" : clp.IsYV12 ? "YV12" : clp.IsYUY2 ? "YUY2"
\ : clp.IsYV16 ? "YV16" : clp.IsYV24 ? "YV24"
\ : clp.Is420 ? "YUV420" : clp.IsYV411 ? "YUV411" : clp.Is422 ? "YUV422" : clp.Is444 ? "YUV444"
\ : ""
MyColorSpace == "Y8" ? ConverttoY8(pp2)
\ : MyColorSpace == "YUV411" ? ConverttoYUV411(pp2)
\ : MyColorSpace == "YV12" ? ConverttoYV12(pp2)
\ : MyColorSpace == "YV16" ? ConverttoYV16(pp2)
\ : MyColorSpace == "YUY2" ? ConverttoYUY2(pp2)
\ : MyColorSpace == "YV24" ? Converttoyv24(pp2)
\ : MyColorSpace == "Y" && Bpc == 10 ? ConverttoY(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV420" && Bpc == 10 ? ConverttoYUV420(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV411" && Bpc == 10 ? ConverttoYUV411(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV422" && Bpc == 10 ? ConverttoYUV422(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "YUV444" && Bpc == 10 ? ConverttoYUV444(pp2).ConvertBits(bits=10)
\ : MyColorSpace == "Y" && Bpc == 12 ? ConverttoY(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV420" && Bpc == 12 ? ConverttoYUV420(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV411" && Bpc == 12 ? ConverttoYUV411(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV422" && Bpc == 12 ? ConverttoYUV422(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "YUV444" && Bpc == 12 ? ConverttoYUV444(pp2).ConvertBits(bits=12)
\ : MyColorSpace == "Y" && Bpc == 14 ? ConverttoY(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV420" && Bpc == 14 ? ConverttoYUV420(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV411" && Bpc == 14 ? ConverttoYUV411(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV422" && Bpc == 14 ? ConverttoYUV422(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "YUV444" && Bpc == 14 ? ConverttoYUV444(pp2).ConvertBits(bits=14)
\ : MyColorSpace == "Y" && Bpc == 16 ? ConverttoY(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV420" && Bpc == 16 ? ConverttoYUV420(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV411" && Bpc == 16 ? ConverttoYUV411(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV422" && Bpc == 16 ? ConverttoYUV422(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "YUV444" && Bpc == 16 ? ConverttoYUV444(pp2).ConvertBits(bits=16)
\ : MyColorSpace == "Y" && Bpc == 32 ? ConverttoY(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV420" && Bpc == 32 ? ConverttoYUV420(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV411" && Bpc == 32 ? ConverttoYUV411(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV422" && Bpc == 32 ? ConverttoYUV422(pp2).ConvertBits(bits=32)
\ : MyColorSpace == "YUV444" && Bpc == 32 ? ConverttoYUV444(pp2).ConvertBits(bits=32)
\: ""
my_second_clip=last
my_first_clip=clp
StackVertical(my_first_clip, my_second_clip)
}
As you can tell from the script, the way they work is to get the properties from the first clip as a reference to apply a quick and dirt conversion to the second clip so that the two properties match and the two clips can therefore be stacked.
I just tested it by feeding Color Bars to it with different resolutions and color spaces and it worked:
As to the fact of picking up more files via FFASTrans, the way it works can be a bit tricky.
This is because in monitors like the P2 watchfolder, we know what we're looking for and we know the structure of such a folder, the .xml in it, and therefore we know when to stop, but with normal watchfolders with random files we don't.
One of the things that can actually be done is to look for a .txt in which you're gonna write the name of the two files that you need to Stack and then use that to generate variables that are gonna populate two ffms2 call and each one is gonna be used in the Custom Avisynth Script as source, namely as video1 and video2 like so:
Code: Select all
video1=FFMpegSource2(source1, atrack=-1)
video2=FFMpegSource2(source2, atrack=-1)
StackMeHorizontal(video1, video2)
where "source1" and "source2" are two variables that contain the path and the name with the extension of the files picked up by the watchfolder using the .txt method.
Still, the bad thing about this would be that you're only gonna pick the first audio channel automatically and you won't have any control over sources with several different audio channels all encoded in a different stream (namely discrete audio channels)...
One other thing you won't have control on is the interlacing stuff.
In the drafts of the functions I wrote, I assumed that both sources were progressive, but that might not be the case.
I should actually put in there something like:
and then bob "clp" as well to get the same framerate in the end...
Anyway, it's 40 minutes past 1 in the morning (1.40AM) and I have an exam coming up on November 16th about coding in Java, so I should really go back to study xD
As to the .txt method, I think there are way better methods, but that's more processors/watchfolders/variables related and less Avisynth-related, so I'll hand over to emcodem on this