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 7th July 2008, 07:36   #1  |  Link
Alex-Kid
Antronio's DV ambassador
 
Alex-Kid's Avatar
 
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
Animated overlay with transparency

Hi everybody.

I've always visited this forum as a knowledge source in every video job i've done. Now it's time to make a question because I still haven't found what I'm looking for (yes, i like U2 ).

I started a week ago editing some baby fútbol (smallest field with five players) material I've filmed. Every goal scored must have an animated overlay (similar to euro 2008) showing name of the player and time of scoring everytime a goal has occured. The overlay is a sequence of PNG images with transparency enabled (with fade in and out)and the text is shown through subtitles (fading out together with overlay). The script I'm using is as follows:

Code:
testcard = avisource("petazetas_vs_mamaestapresa.avi").ConvertToRGB32()
tcard01 = testcard.trim(8587,8757)
subs = ImmaRead("gol%02d.png", start=1, end=45)
logo = Overlay(tcard01, subs, 165, 280, ShowAlpha(subs), 255, "blend")
dissolve(trim(testcard, 0, 8586),logo,trim(testcard,8758,24546),5)
subtitle("JUAN CASTILLO", 230, 287, 8622, 8752, "Arial Narrow Cursiva", 16, $00ffffff, $ff000000, 7)
subtitle("MIN. 51", 248, 307, 8622, 8752, "Arial Narrow Cursiva", 14, $00ffffff, $ff000000, 7)
converttoyv12()
At this time, there's only one issue with dissolve ranges, easy to solve. But there are another issues I think they can be enhanced:
  1. The trim/dissolve filters must be used for showing the overlay from the beginning (if not, it starts from frame 0 of testcard, and the animation gets lost).
  2. Subtitles have not fading out. Anybody, please?
  3. This script shows only one goal. The matches have often 5-8 goals average, so the overlay must be showed many times. Can memory issues occur (overlay called several times)?
  4. Finally, Would be better to make a function for this?

Thanks in advance. Saludos

By ALEX-KID
Alex-Kid is offline   Reply With Quote
Old 7th July 2008, 09:00   #2  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Code:
testcard = avisource("petazetas_vs_mamaestapresa.avi")

subs = ImmaRead("gol%02d.png", start=1, end=45)

Goal(testcard, subs,  8587, "JUAN CASTILLO", "MIN. 51")
Goal(testcard, subs, 17007, "JOSE FANGIO", "MIN. 101")
...

Function Goal(clip src, clip sub, int start, string text1, string text2) {

  ol = 5 # Dissolve duration
  fc = FrameCount(sub) # Animation duration
  tl = 130 # Text duration

  v1 = src.trim(0, -start-ol)
  tc = src.trim(start, -fc-ol)
  tx = src.trim(start+fc, -tl)
  v2 = src.trim(start+fc+tl-ol, 0)

  tc = tc.Overlay(sub, 165, 280, ShowAlpha(sub), 1.0, "blend")

  tx = tx.subtitle(text1, 230, 287, 0, tl, "Arial Narrow Cursiva", 16, $00ffffff, $ff000000, 7)
  tx = tx.subtitle(text2, 248, 307, 0, tl, "Arial Narrow Cursiva", 14, $00ffffff, $ff000000, 7)

  return dissolve(v1, tc, tx, v2, ol)
}
From your frame numbers I have assumed you want the text to follow the animation, if you want them at the same time it is a simple matter to adjust the Goal function.
IanB is offline   Reply With Quote
Old 9th July 2008, 21:06   #3  |  Link
Alex-Kid
Antronio's DV ambassador
 
Alex-Kid's Avatar
 
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
After a lot of thinking about what the script does, I finally can write reply ...

I had some issues with sub/subs variable, but were easy to solve. The video was split in four parts, where the second one and third one contain the overlay and the subtitles repectively. Then the video is rejoined through Dissolve filter, but when showing subtitles, the overlay is gone and it's needed as a background for the subtitles. So my attempt is to add another image, make the overlay and add the text. Like this:
Code:
testcard = avisource("petazetas_vs_mamaestapresa.avi")

sub = ImmaRead("gol%02d.png", start=1, end=45)
sub0 = ImmaRead("gol45.png")

Goal(testcard, sub,  8587, "JUAN CASTILLO", "MIN. 51")
Goal(testcard, sub, 17007, "JOSE FANGIO", "MIN. 101")
...

Function Goal(clip src, clip sub, int start, string text1, string text2) {

  ol = 5 # Dissolve duration
  fc = FrameCount(sub) # Animation duration
  tl = 130 # Text duration

  v1 = src.trim(0, -start-ol)
  tc = src.trim(start, -fc-ol)
  tx = src.trim(start+fc, -tl)
  v2 = src.trim(start+fc+tl-ol, 0)

  tc = tc.Overlay(sub, 165, 280, ShowAlpha(sub), 1.0, "blend")

  tx = tx.Overlay(sub0, 165, 280, ShowAlpha(sub), 1.0, "blend")
  tx = tx.subtitle(text1, 230, 287, 0, tl, "Arial Narrow Cursiva", 16, $00ffffff, $ff000000, 7)
  tx = tx.subtitle(text2, 248, 307, 0, tl, "Arial Narrow Cursiva", 14, $00ffffff, $ff000000, 7)

  return dissolve(v1, tc, tx, v2, ol)
}
It doesn't seem too elegant (to me). Any improvements are welcome.
But this script only works for the last Goal function specified, I don't know how to make it work for each goal scored.

Help is needed again.

Saludos

By ALEX-KID
Alex-Kid is offline   Reply With Quote
Old 9th July 2008, 23:13   #4  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Ah, so IanB's earlier assumption was mistaken.

Quote:
Originally Posted by IanB View Post
From your frame numbers I have assumed you want the text to follow the animation, if you want them at the same time it is a simple matter to adjust the Goal function.
I think the adjustment you need is something like this:
Code:
Function Goal(clip src, clip sub, int start, string text1, string text2) {

  ol = 5 # Dissolve duration
  tl = 130 # Text duration
  ts = 30 # Text start relative to animation
  fc = tl+ts # Total animation duration

  v1 = src.trim(0, -start-ol)
  tc = src.trim(start, -fc-ol)
  v2 = src.trim(start+fc, 0)

  tc = tc.Overlay(sub, 165, 280, ShowAlpha(sub), 1.0, "blend")
  tc = tc.subtitle(text1, 230, 287, ts, fc-1, "Arial Narrow Cursiva", 16, $00ffffff, $ff000000, 7)
  tc = tc.subtitle(text2, 248, 307, ts, fc-1, "Arial Narrow Cursiva", 14, $00ffffff, $ff000000, 7)

  return dissolve(v1, tc, v2, ol)
}
Here I am assuming that the last (45th) frame of your .png sequence is simply repeated as a static background behind the text, which is what your original example suggests.
Gavino is offline   Reply With Quote
Old 9th July 2008, 23:49   #5  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Right I misunderstood what you wanted. You want the last frame of the .PNG's repeated thru the text. And oops forgot to remove the "testcard="
Code:
Function Goal(clip src, clip sub, int start, string text1, string text2) {

  ol = 5 # Dissolve duration
  fc = FrameCount(sub) # Animation duration
  tl = 130 # Text duration

  v1 = src.trim(0, -start-ol)
  tc = src.trim(start, -fc-tl-ol)
  v2 = src.trim(start+fc+tl, 0)

  tc = tc.Overlay(sub, 165, 280, ShowAlpha(sub), 1.0, "blend")

  t1 = tc.trim(0, -fc-ol)
  t2 = tc.trim(fc, 0)

  t2 = t2.subtitle(text1, 230, 287, 0, tl, "Arial Narrow Cursiva", 16, $00ffffff, $ff000000, 7)
  t2 = t2.subtitle(text2, 248, 307, 0, tl, "Arial Narrow Cursiva", 14, $00ffffff, $ff000000, 7)

  return dissolve(v1, t1, t2, v2, ol)
}

subs = ImmaRead("gol%02d.png", start=1, end=45)

avisource("petazetas_vs_mamaestapresa.avi")

Goal(subs,  8587, "JUAN CASTILLO", "MIN. 51")
Goal(subs, 17007, "JOSE FANGIO", "MIN. 101")
...
IanB is offline   Reply With Quote
Old 10th July 2008, 00:17   #6  |  Link
Alex-Kid
Antronio's DV ambassador
 
Alex-Kid's Avatar
 
Join Date: Mar 2006
Location: Santiago, Chile
Posts: 115
NIIICE!!

Thank you IanB. And thank you too Gavino for trying. I knew avisynth could do it, so long life avisynth!

Saludos

By ALEX-KID
Alex-Kid is offline   Reply With Quote
Reply

Tags
animated, logo, overlay, transparency

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 06:34.


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