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 29th August 2018, 17:32   #1  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 279
Create an opaque box

Can anyone suggest an easy way to create an opaque box of a color anywhere on the screen? Ideally anywhere, but in particular, I need to place a box in one corner of the screen. I'll be overlaying text on top of it.

Isn't there somewhere where users have created functions and shared them with the world? (A repository for Avisynth scripts.) I can't find such.
TCmullet is offline   Reply With Quote
Old 29th August 2018, 18:04   #2  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,096
Some code I had lying around that should get you started:

Code:
bord1=64
baseclip=AVISource("E:\Documents\Dnload\UNPACK\bandstand.avi")
blank_white=  Blankclip(baseclip, width=bord1,height=bord1, color=$FFFFFF)
final= overlay(baseclip,blank_white, x=40,y=300) 
return final
johnmeyer is offline   Reply With Quote
Old 29th August 2018, 19:06   #3  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 279
Thanks, John. Could you please help me a bit more? I've incorporated the logic into my own small function, a function that shows a sports scoreboard (rudimentary). I have working the subtitle, but wanted to add a black background. Am now merely trying to get a black box to show, but it doesn't. Here's my whole code:
Code:
function Scores(clip myclip, int "score1", int "score2", \
 int "fstart", int "fend", \
 string "team1", string "team2", string "gamelabel", \
 int "frow", int "fcol")
{
blank_black=Blankclip(myclip, width=100,height=100, color=$000000)
overlay(myclip,blank_black,x=0,y=0,mode="darken") 

scoreboard = gamelabel + ":  " + team1 + " " + string(score1) + ", " + \
 team2 + " " + string(score2)

Subtitle(myclip, scoreboard, x=frow, y=fcol,  \
    font="Arial", size=30, lsp=0, spc=0, font_width=0, \
    first_frame=fstart, last_frame=fend)
}
Any idea of why my 100 x 100 black box does not appear at all? The Scores function has been working and still does, but I get no black box anywhere. (Initially I'm simply trying to get the box on the screen, then lay the text over whatever is there. I'll worry about computing the dimensions etc. after I get the box visible.)

Last edited by TCmullet; 29th August 2018 at 19:12.
TCmullet is offline   Reply With Quote
Old 29th August 2018, 19:45   #4  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 279
The above code had serious flaws. I've improved by creating this, and still no black box appears:

Code:
function paintbox(clip clp, int "fstart", int "fend")
{
a=trim(clp,0,fstart-1)
b=trim(clp,fstart,fend)
c=trim(clp,fend+1,0)
blank_black=Blankclip(b, width=100,height=100, color=$000000)
overlay(b,blank_black,x=0,y=0,mode="darken") 
b=last
return a++b++c
}

function Scores(clip myclip, int "score1", int "score2", \
 int "fstart", int "fend", \
 string "team1", string "team2", string "gamelabel", \
 int "frow", int "fcol")
{
scoreboard = gamelabel + ":  " + team1 + " " + string(score1) + ", " + \
 team2 + " " + string(score2)
paintbox(myclip, fstart, fend)
Subtitle(myclip, scoreboard, x=frow, y=fcol,  \
    font="Arial", size=30, lsp=0, spc=0, font_width=0, \
    first_frame=fstart, last_frame=fend)
}
My function calls further down the script look like:

Code:
Scores(3,3,2992,3681,"Texas","Oregon","Set 2",0,0)
Scores(4,3,3681,4678,"Texas","Oregon","Set 2",0,0)
Scores(4,4,4678,5441,"Texas","Oregon","Set 2",0,0)
I'm expecting that whenever my subtitle appears, which is in upper left corner, it will now have a black 100x100 box under it. The box blots out the video image, then the text blots out part of both. But I see no evidence of the box.

Last edited by TCmullet; 29th August 2018 at 20:11.
TCmullet is offline   Reply With Quote
Old 29th August 2018, 20:17   #5  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,647
Code:
paintbox(myclip, fstart, fend)
Subtitle(myclip, scoreboard, x=frow, y=fcol,  \
    font="Arial", size=30, lsp=0, spc=0, font_width=0, \
    first_frame=fstart, last_frame=fend)
You're not assigning the result of paintbox to anything. It ends up in implicit last, but you call subtitle with myclip, which is the original clip.

Do either:

Code:
boxed_clip=paintbox(myclip, fstart, fend)
subtitle(boxed_clip, scoreboard...
or

Code:
paintbox(myclip, fstart, fend)
subtitle(scoreboard...
Removing the clip from the call to subtitle makes it use the implicit last.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 29th August 2018, 20:37   #6  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 279
I did the latter (removing clip from call to subtitle), and it worked. But when I remove the clip from the call to paintbox, I get an error. Why does paintbox need the clip but subtitle doesn't?
TCmullet is offline   Reply With Quote
Old 29th August 2018, 21:09   #7  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 1,647
At the point in the script where paintbox is called, there isn't any implicit "last" clip (which is the current "default" clip, also accessible with the keyword "last"). You could set one and then call paintbox like this:

Code:
myclip
paintbox(fstart, fend)
Avisynth knows that paintbox wants a clip as its first parameter, so if you don't give it one, it will use last (if there is a clip there, that is).
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 30th August 2018, 06:29   #8  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 279
Thanks to both you guys! David, ah yes, I OFTEN get bit by "script does not end with clip".

I'll try to post my finished and refined "sports scoreboard" here when I finish it.
TCmullet 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 18:45.


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