Log in

View Full Version : How to overlay multiple scrolling images into a stream?


Woodlake
21st January 2016, 14:17
Hi Guys,

Just looking for a little help with a script.
There seems to be plenty of info on scrolling subtitles, but nothing to achieve exactly what I'm after.
This is the goal:
I have a 1920x1080 letterboxed video of guitar playing. In the lower black bar I want to scroll the tablature/music to match the video.
I have succeeded in doing it for a single bar (1920x160px image), but I need successive bars to follow on in a continuous unbroken stream.
Due to the length of the song (102 bars), it is impractical to do it with a single image (195840x160px!!).

Here is the script I have so far:

V = FFVideoSource("song.mp4")
A = FFAudioSource("song.mp4").DelayAudio(-0.2)
# Delay before the playing starts (trimmed since overaly works from 1st frame)
part1 = AudioDub(V, A).Trim(0,100).ConvertToYUY2
# guitar part
part2 = AudioDub(V, A).Trim(101,0).ConvertToYUY2
# single bar image
tab = ImageSource("Y:\Avs Files\song\TAB\001.jpg")
# thin vertical red line to indicate location on TAB (static)
pointer = ImageSource("Y:\Avs Files\song\TAB\Pointer.png")
pointer2 = ImageSource("Y:\Avs Files\song\TAB\Pointer.png",pixel_type="RGB32").ShowAlpha(pixel_type="RGB32")
# animating movement of the 1 bar image
Comp = Animate(part2, 48, 200, "overlay", tab, 0, 917, tab, -1920, 917)
# combining pre play part with final video and overlays
Final = Overlay (Comp,pointer,mask=pointer2, 0, 917)
AlignedSplice(part1,Final)

Any suggestions as to how this could be achieved?

Cheers,
Woodlake

StainlessS
21st January 2016, 22:20
Well first off you can drop all of the guitar stuff, that is just complicating matters, just do a repost of the
stuff relating to creating the bottom border, you can add the video/audio and delay yourself without
obfuscating your post.

Also, post half a dozen of your single bar images (not the pointer stuff, can also do later). EDIT: Probably not necessary, see below.

EDIT: Dont know if I have time to assist, but above would make it easier for others to.

EDIT: This produces a clip just fine on my XP32 core duo, so not that impractical.


BlankClip(Width=19580,Height=160)


Try doing a Resize using Animate adjusting crop coords.

EDIT: Do search on, Animate, by user IanB, Posts not threads.

Here is one result:- http://forum.doom9.org/showthread.php?p=1609992&highlight=animate#post1609992

EDIT: Also search same, but for user Gavino, heres one:- http://forum.doom9.org/showthread.php?p=1682270&highlight=animate#post1682270

StainlessS
22nd January 2016, 02:26
Here you are Woody, (demo)

MakeTab.avs

# Make Dummy test clip, write as BMP files

W=256 H=32 L=40

BlankClip(Width=W,Height=H,Length=L)

Scriptclip("""
RT_Subtitle("[%d] This is tab %d ABCDEFG",current_frame,current_frame,Align=4)
""")

ImageWriter("%06d.BMP",start=0,End=FrameCount-1,type="BMP")

Return Last


Scroller.avs

END = 40 - 1 # Number of BMP files - 1

ImageSource("%06d.bmp",Start=0,End=END)

W=Width H=Height

OUTW = 640 OUTH = 48 OUTFRAMES=1000 # Output clip dimensions and length
Blank = BlankClip(Width=W,Height=H,Length=1)

Canvas = Blank # Left edge Spare
GSCript("""
# Make WIDE single frame of TAB
for(i=0,FrameCount-1) {
TabFrame = Trim(i,-1) # Trim single frame at i
Canvas = StackHorizontal(Canvas,TabFrame) # Glue it on to RHS of wide frame
}
""")
Canvas = StackHorizontal(Canvas,Blank) # Right edge Spare

### Crop any pixels off here from Left or Right edges, as required. (spare TAB frame width at each end)
# ... Canvas = Canvas.Crop(W,0,-W,-0) # CROP off BOTH left and right SPARE blocks
####

#Return Canvas # Really wide frame, perhaps with Spare blocks cropped off

Canvas = Canvas.Loop(OUTFRAMES,0,0) # Make WIDE clip of OUTFRAMES frames (all identical)

Canvas.Animate(0,OUTFRAMES-1,"Spline36Resize",
\ OUTW,OUTH, 0.0 , 0.0, W,H,
\ OUTW,OUTH, Float(Canvas.Width-W), 0.0, W,H
\ )

Return Last

Woodlake
22nd January 2016, 02:48
Here you are Woody, (demo)

[/Code]

Thanks very much Stainless - I really apprecaite the help.
I'll take some time to digest what you've come up with.
Many Thanks,
Woodlake

Ok - running the script seems to achieve the desired result - thanks you!
I am not familiar with GScript, so I need to work through your syntax and determine how I can impliment it into my original script.
Thanks again Stainless

StainlessS
22nd January 2016, 03:54
Removed unnecessary lines out of GScript section, perhaps easier to figure out.

The GScript bit just stacks horizontal all TAB BMPs into a single wide frame,
with a SPARE blank TAB width bit of image at left and right edges
(Spare = inital BLACK block, scroll in and out).
The spare black tabs are added, before and after the GScript section.

EDIT: Added

# ... Canvas = Canvas.Crop(W,0,-W,-0) # CROP off BOTH left and right SPARE blocks


Removes both SPARE left and right blocks (ie text immediate start and end, no black lead in or out)

Woodlake
22nd January 2016, 04:11
Ah OK - thanks for the explanation, it achieves exactly what I was looking for, however I seem to get an error if I try and use a jpg instead of bmp:

StackHorizontal: image formats don't match

Will it only work with bmp images?

Nevermind - I figured out that I needed to add pixel_type to the imagesource to get around the mismatch...

Woodlake
22nd January 2016, 04:27
Intergrated into my original script and working perfectly!
Thank you very much Stainless for your help.

Woodlake