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. |
28th January 2019, 19:54 | #1 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
TitleBar v1.02 - 04 Feb 2019
Code:
TitleBar() - by StainlessS @ Doom9:- https://forum.doom9.org/showthread.php?t=176062 Requires VS2008 CPP Runtimes. VIDEO: Planar, YUY2, RGB32, & RGB24. Plugin's for both Avisynth v2.58 and v2.6 (avs+ x86 & x64). Filter to Add a 20 pixel Black TitleBar to top of clip, and to write a title string and optional Frame Number to each frame. Uses DDigit text renderer & where showing FrameNumber, does not require ScriptClip() filter call. Titlebar(clip c,String "Tit"="",Bool "ShowFrameNo"=False,Int "Col"=$000000,String "ColChr"="",Bool "Esc"=True) Tit, Default "", Title string to write above video clip to the TitleBar. The Tit title string may also contain Escape codes if Esc Arg is True, see later. ShowFrameNo, Default FALSE. If True, then also writes Frame Number as in eg "1234] My Title String". Col, Default $000000. RGB color of the TitleBar background. ColChr, Default "" (Starting Color = default). A single character as a string which sets the Starting color used for printing the FrameNumber/Title text. If the ColChr string contains more than a single character, it will throw an error. Valid single character can be any one of these (upper or lower case):- "0123456789ABCDEF" # 16 Color character codes '0' to 'F' "GHIJKLMNOPQRSTUV" # 16 Greyscale character codes in ascending order of lightness 'G' to 'V' ($00 -> $FF) "-!*" # 3 Specials, # '-' = Default color. : As '7' [White] in Color colorspace : As 'S' [Near white $CC] in Y8. # '!' = HiLite color. : As 'A' [Orange] in Color colorspace : As 'V' [White $FF] in Y8. # '*' = Silently converted to '-', ie Default color. (Only has real meaning embedded in the Tit title string). Esc, Default True. If True, then Escape codes "\a?", and "\x??" can be used to embed data into Tit Title string (The 'a' and 'x' MUST BE LOWERCASE). Where "\a?", '?' is any character valid as in above ColChr, enables changing color on title bar, within the Tit title string. In such a case, "\a*" switches to the OnEntry or Starting color, ie same color as set via ColChr. Where "\x??", each '?' character MUST BE an UPPERCASE hex digit '0' -> 'F'. Enables embedding 8 bit Hex character code into the Tit title string. You can use eg "\\x00" to embed a literal sequence of "\x00" into the title string, ie "\\" embeds a single backslash and so does not interpret as hex insertion code. Use similar to avoid color escape code eg "\\a-" to embed literal "\a-". Esc=False, does NOT process color Escape codes nor Hex insertion Escape code. NOTE, the only character in range 0->31 that can be used in Tit title string is BEL [chr(7)] (where "\a" is converted to BEL color switch code), all other codes in range 0->31 (eg chr(9) TAB) are converted to SPACE character. Also, CarriageReturn(13) and Newline(10) will terminate the title string early, eg you cannot use Newline(10) to print on the input clip [neither as "\n" nor Chr(10)]. Likewise, characters $E0 -> $FF will be converted to SPACE character (they also do not exist in font). eg, # Chr(137) [$C9]is Copyright symbol (c). # EDIT: C9 should read $89 ColChr = "!" # Hilite Code (takes effect from FrameNumber as ShowFrameNumber=True) Return ColorBars.Titlebar("TitleBar \a-\xC9 StainlessS \a*2019",True,ColChr,Esc=true) # FrmNo=Hilite, copyright in Default, Year in same as FrmNo COLOR TABLE:- # Ordinal Color ColChr or eg("\a0" for embedded DARKGRAY) 00) DARKGRAY "0" 01) DODGERBLUE "1" 02) ORANGERED "2" 03) ORCHID "3" 04) LIME "4" 05) AQUAMARINE "5" 06) YELLOW "6" 07) WHITE "7" 08) SILVER "8" 09) CORNFLOWERBLUE "9" 10) ORANGE "A" 11) PLUM "B" 12) CHARTREUSE "C" 13) POWDERBLUE "D" 14) GOLD "E" 15) GAINSBORO "F" # # Grey ColChr 16) $00 "G" 17) $11 "H" 18) $22 "I" 19) $33 "J" 20) $44 "K" 21) $55 "L" 22) $66 "M" 23) $77 "N" 24) $88 "O" 25) $99 "P" 26) $AA "Q" 27) $BB "R" 28) $CC "S" 29) $DD "T" 30) $EE "U" 31) $FF "V" # Specials DEFAULT "-" HILITE "!" ON_ENTRY "*" ################################### TitleBarTest.avs ############ ColorBars(width=1024) # Chr(137) [$89]is Copyright symbol (c). SHOWFRAMENO = true COLCHR = "!" # Hilite Code (takes effect from FrameNumber if ShowFrameNumber=True, Else takes effect on Tit title string) ESC = True Titlebar("Title\aDBar \a-\x89 \a2S\a3t\a4a\a5i\a6n\a8l\a9e\aAs\aBs\aCS \a*2019",ShowFrameNo=SHOWFRAMENO,ColChr=COLCHR,Esc=ESC) ############ StainlessS Zip included 3 dll,s, v2.58, avs/+ 2.60 x86 & x64, + source + full VS2008 project files for easy rebuild. TitleBarTest.avs Code:
ColorBars(width=1024) # Chr(137) [$89]is Copyright symbol (c). SHOWFRAMENO = true COLCHR = "!" # Hilite Code (takes effect from FrameNumber if ShowFrameNumber=True, Else takes effect on Tit title string) ESC = True Titlebar("Title\aDBar \a-\x89 \a2S\a3t\a4a\a5i\a6n\a8l\a9e\aAs\aBs\aCS \a*2019",ShowFrameNo=SHOWFRAMENO,ColChr=COLCHR,Esc=ESC) TitleBar_Characterset.avs Code:
# Req RT_Stats Function TitleBarCharSet() { GS=""" S="" for(y=0,15) { s=s+"$"+RT_Hex(y*16,2)+ " " for(x=0,15) { n=y*16+x c=(n<32 || n > 223) ? "." : Chr(n) s=s+c } s=s+Chr(10) } """ HasGScript=RT_FunctionExist("GScript") HasGScript ? GScript(GS) : Eval(GS) # Use GSCript if installed Else need AVS+ Return S } BlankClip S=TitleBarCharSet RT_Subtitle("%s",S) ShowColorCodes.avs Code:
# Req RT_Stats: Show Colors S="""\a!\\a! HILITE \a-\\a- DEFAULT \a0\\a0 DARKGRAY \a1\\a1 DODGERBLUE \a2\\a2 ORANGERED \a3\\a3 ORCHID \a4\\a4 LIME \a5\\a5 AQUAMARINE \a6\\a6 YELLOW \a7\\a7 WHITE \a8\\a8 SILVER \a9\\a9 CORNFLOWERBLUE \aA\\aA ORANGE \aB\\aB PLUM \aC\\aC CHARTREUSE \aD\\aD POWDERBLUE \aE\\aE GOLD \aF\\aF GAINSBORO \aG\\aG Y_0 \aH\\aH Y_1 \aI\\aI Y_2 \aJ\\aJ Y_3 \aK\\aK Y_4 \aL\\aL Y_5 \aM\\aM Y_6 \aN\\aN Y_7 \aO\\aO Y_8 \aP\\aP Y_9 \aQ\\aQ Y_A \aR\\aR Y_B \aS\\aS Y_C \aT\\aT Y_D \aU\\aU Y_E \aV\\aV Y_F""" blankClip(Height=34*20) RT_Subtitle(S) EDIT: Alternative using Subtitle, should be fast if NOT using FrameNumbering Code:
# Stack Overhead Subtitle Text, with optional FrameNumber shown. Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){ c.BlankClip(height=20,Color=Default(Col,0)) (Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit) Return StackVertical(c).AudioDubEx(c) } EDIT: Damn, ShowFrameNo default was changed to False, but forgot to change in docs to False.
__________________
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; 4th February 2019 at 17:30. Reason: Update |
28th January 2019, 21:13 | #2 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
I like it, very nice.
What's up with the closing square bracket after the frame number? Why no opening bracket (or none)? It looks a bit orphaned.
__________________
Groucho's Avisynth Stuff Last edited by Groucho2004; 28th January 2019 at 21:33. |
29th January 2019, 01:20 | #4 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Actually, is currently a wee bit slower than desired.
The TSub() function without showing FrameNo is already real fast [I also since initial post, added the Trim(0,-1) prior to .Subtitle(Tit), which sped it up about 100 FPS on colorbars clip]. I've since posting, done some timing tests, and mods to source, using a source filter for black titlebar only, and then StackVertical as in TSub function, so as to use really on fast intrinsics or bliting or whatever to to do the stacking, quicker than my C code. Also, the internal source filter for the black titlebar keeps a copy of single frame if not showing frame number, so as to avoid writing title at every frame. Is now somewhat faster, will post update tomorrow probably, gonna change arg FrameNo to ShowFrameNo and with default false, to match the TSub function. Timing on colorbars in comments (FPS) Code:
colorbars #TSub("hello",false) # 4548 #TSub("hello",true) # 1134 #titlebar("hello",false) # 4555 #titlebar("hello",True) # 4019 return last Code:
AviSource("d:\g.avi") #TSub("hello") # 750 #TSub("hello",true) # 469 #titlebar("hello",False) # 753 titlebar("hello",True) # 732 return last EDIT: Quote:
__________________
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; 29th January 2019 at 01:26. |
|
29th January 2019, 01:28 | #5 | Link |
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
|
__________________
Groucho's Avisynth Stuff |
29th January 2019, 10:34 | #6 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Not tested yet but can't be this done using native commands and not using scriptclip like in 1st post alternative method ?
something like : Code:
clip=ColorBars font_height=25 font_used="Arial" clip.AddBorders(0,20,0,0).ShowFrameNumber(scroll=false,offset=0,x=font_height/8,y=font_height/1.6,font=font_used,size=font_height,text_color=$ffffff) \ .Subtitle("Name of the video",y=-4,align=8 ,font=font_used,size=font_height,text_color=$ffffff) Not sure how it compares in terms of rendering speed tho. |
29th January 2019, 14:47 | #7 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Tested the x64 dll and unlike on your benchs results there is barely any difference when setting true or false for me, not sure what is going on and seems strange when comparing with your results.
Code:
ColorBars.Tsub("hello",false) # 17886 ColorBars.Tsub("hello",true) # 2664 ColorBars.Titlebar("hello",false) # 2683 ColorBars.Titlebar("hello",True) # 2660 Code:
c=ColorBars d=BlankClip(height=20, color=$000000, length= c.FrameCount).ShowFrameNumber(scroll=false,offset=0,x=25/8,y=25/1.5,size=25,text_color=$ffffff).Subtitle("hello",y=-4,align=8,size=25,text_color=$ffffff) d.StackVertical(c).AudioDubEx(c) Also tried to see if i could modify your function to include "ShowFrameNumber" instead of scriptclip but got this partially working only, i'm not good at functions... anyways came up with this : Code:
Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){ c.BlankClip(height=20,Color=Default(Col,0)) (Default(ShowFrameNo,False))?ShowFrameNumber(scroll=false,offset=0,x=25/8,y=25/1.5,size=25,text_color=$ffffff):Trim(0,-1).Subtitle(Tit,y=-4,align=8,size=25,text_color=$ffffff) Return StackVertical(c).AudioDubEx(c) } colorbars.TSub("hello",true) Still tried to simulate performances and bench it Code:
colorbars.TSub("hello",false) Then tried to simulate the title displaying in the middle like this Code:
colorbars.TSub("hello",false).Subtitle("hello",y=-4,align=8,size=25,text_color=$ffffff) Finally tried the sub setting set to true + additional sub : Code:
colorbars.TSub("hello",true).Subtitle("hello",y=-4,align=8,size=25,text_color=$ffffff) Not sure what i am doing wrong with the modified function and why i can only get the fps or the text but not both displayed at the same time, like i said I'm not really good at avisynth functions, you guys who are guru's for this might find the issue with your expert eyes. I remain intrigued by the x64 dll and why there is not much differences on my tests when fps are displayed or not compared to StainlessS's results, not sure if i should to try compile it myself later or tomorrow and see if it gets better. Well that's all for now Last edited by Yanak; 29th January 2019 at 14:50. |
29th January 2019, 17:08 | #8 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Given timings are for MY current version, posted version is very defo slower. (I just assumed that it would be faster than Subtitle), think maybe is related to Avs+, maybe something done
to dramatically speed Subtitle (caching or whatever). Here some other Subs related funcs. Code:
# Stack Overhead Subtitle Text, with optional FrameNumber shown. Function TSub(clip c,string Tit,Bool "ShowFrameNo",Int "Col"){ c.BlankClip(height=20,Color=Default(Col,0)) (Default(ShowFrameNo,False))?ScriptClip("""Subtitle(String(current_frame,"%.f] """+Tit+""""))"""):Trim(0,-1).Subtitle(Tit) Return StackVertical(c).AudioDubEx(c) } Function Sub(clip c,string Tit,Bool "ShowFrameNo",int "first_frame", int "last_frame",string "font",float "size",int "text_color", \ int "halo_color",int "align",int "spc",float "font_width",float "font_angle",Int "BackColor") { /* Stack Overhead Subtitle Text, with optional FrameNumber shown http://forum.doom9.org/showthread.php?p=1813402#post1813402 Title bar is Round(size+2) pixels hi (default 20). Dont use align=4,5,6, better use 1,2,3,7,8,or 9. */ ShowFrameNo=Default(ShowFrameNo,False) first_frame=Default(first_frame,0) last_frame=Default(last_frame,c.FrameCount-1) font=default(font,"Ariel") size=Default(size,18.0) text_color=Default(text_color,$00FFFF00) halo_color=Default(halo_color,$00000000) align=default(align,7) spc=Default(spc,0) font_width=Default(font_width,0) font_angle=Default(font_angle,0.0) BackColor=Default(BackColor,$00000000) c.BlankClip(height=round(size+2.0),Color=BackColor) (ShowFrameNo) \ ? ScriptClip("""Subtitle(String(current_frame,"%.0f] ")+"""+Chr(34)+Tit+Chr(34)+String(first_frame,",first_frame=%.0f")+ \ String(last_frame,",last_frame=%.0f,font=")+Chr(34)+font+Chr(34)+String(size,",size=%.3f")+String(text_color,",text_color=%.0f")+ \ String(halo_color,",halo_color=%.0f")+String(align,",align=%.0f")+String(spc,",spc=%.0f")+String(font_width,",font_width=%.3f")+ \ String(font_angle,",font_angle=%.3f)")) \ : Subtitle(Tit,first_frame=first_frame,last_frame=last_frame,font=font,size=size,text_color=text_color,halo_color=halo_color,align=align, \ spc=spc,font_width=font_width,font_angle=font_angle) Return StackVertical(c).AudioDubEx(c) } # Stack Overhead RT_Subtitle Text, with optional FrameNumber shown. Function RtSub(clip c,string Tit, Bool "ShowFrameNo") { c.BlankClip(height=20) (Default(ShowFrameNo,False)) ? ScriptClip("""RT_Subtitle("%d] %s",current_frame,""""+Tit+"""")""") : RT_Subtitle("%s",Tit) Return StackVertical(c).AudioDubEx(c) } Function SubV(clip c, string text, float "x", float "y", int "first_frame", int "last_frame", string "font", float "size", \ int "text_color", int "halo_color", int "align", int "spc", int "lsp", float "font_width", float "font_angle", bool "interlaced", \ bool "vcenter") { # http://forum.doom9.org/showthread.php?p=1628899#post1628899 c GScript(""" size=Default(size,18) vcenter=Default(vcenter,false) if(Defined(align) && Defined(lsp)) { if((align>=4 && align<=6) && vcenter) { s=RT_StrReplace(text,"\n",Chr(10),Sig=false) Lines = RT_TxtQueryLines(s) # Line count with/without final newline y=(Height/2) - ((Lines-1) * (size + lsp/8.0) / 2.0) } else if(align>=1 && align<=3) { s=RT_StrReplace(text,"\n",Chr(10),Sig=false) Lines = RT_TxtQueryLines(s) # Line count with/without final newline y=Height - ((Lines-1) * (size + lsp/8.0)) } } """) Subtitle(text,x,y,first_frame,last_frame,font,size,text_color,halo_color,align,spc,lsp,font_width,font_angle,interlaced) } EDIT: On 64 bit, getting significant speed increases for both TSub and Titlebar. EDIT: NOTE, RtSub(), can embed color control codes in the title text and so have multi-color text title. eg Code:
# Stack Overhead RT_Subtitle Text, with optional FrameNumber shown. Function RtSub(clip c,string Tit, Bool "ShowFrameNo") { c.BlankClip(height=20) (Default(ShowFrameNo,False)) ? ScriptClip("""RT_Subtitle("%d] %s",current_frame,""""+Tit+"""")""") : RT_Subtitle("%s",Tit) Return StackVertical(c).AudioDubEx(c) } Return ColorBars.RTSub("TitleBar " +CHR(137) +" "+ Chr(7)+ "!StainlessS" + Chr(7) + "- 2019",True) # Chr(137) is Copyright symbol (c). # Chr(7) [BEL] is color control code, '!' is HiLite(orange), '-' is normal white. Or same Code:
S=RT_String("TitleBar %c \a!StainlessS \a- 2019",137) # EDIT '\a' embeds BEL ie Chr(7), so '\a!' is color control code for Hilite in Orange, and '\a-' back to white. Return ColorBars.RTSub(S,True) # Chr(137) is Copyright symbol (c). Code:
\a! DDIGIT_CC_HILITE \a- DDIGIT_CC_DEFAULT \a0 DDIGIT_CC_DARKGRAY \a1 DDIGIT_CC_DODGERBLUE \a2 DDIGIT_CC_ORANGERED \a3 DDIGIT_CC_ORCHID \a4 DDIGIT_CC_LIME \a5 DDIGIT_CC_AQUAMARINE \a6 DDIGIT_CC_YELLOW \a7 DDIGIT_CC_WHITE \a8 DDIGIT_CC_SILVER \a9 DDIGIT_CC_CORNFLOWERBLUE \aA DDIGIT_CC_ORANGE \aB DDIGIT_CC_PLUM \aC DDIGIT_CC_CHARTREUSE \aD DDIGIT_CC_POWDERBLUE \aE DDIGIT_CC_GOLD \aF DDIGIT_CC_GAINSBORO \aG DDIGIT_CC_Y_0 \aH DDIGIT_CC_Y_1 \aI DDIGIT_CC_Y_2 \aJ DDIGIT_CC_Y_3 \aK DDIGIT_CC_Y_4 \aL DDIGIT_CC_Y_5 \aM DDIGIT_CC_Y_6 \aN DDIGIT_CC_Y_7 \aO DDIGIT_CC_Y_8 \aP DDIGIT_CC_Y_9 \aQ DDIGIT_CC_Y_A \aR DDIGIT_CC_Y_B \aS DDIGIT_CC_Y_C \aT DDIGIT_CC_Y_D \aU DDIGIT_CC_Y_E \aV DDIGIT_CC_Y_F Code:
Colorbars.KillAudio S="""\a!\\a! DDIGIT_CC_HILITE \a-\\a- DDIGIT_CC_DEFAULT \a0\\a0 DDIGIT_CC_DARKGRAY \a1\\a1 DDIGIT_CC_DODGERBLUE \a2\\a2 DDIGIT_CC_ORANGERED \a3\\a3 DDIGIT_CC_ORCHID \a4\\a4 DDIGIT_CC_LIME \a5\\a5 DDIGIT_CC_AQUAMARINE \a6\\a6 DDIGIT_CC_YELLOW \a7\\a7 DDIGIT_CC_WHITE \a8\\a8 DDIGIT_CC_SILVER \a9\\a9 DDIGIT_CC_CORNFLOWERBLUE \aA\\aA DDIGIT_CC_ORANGE \aB\\aB DDIGIT_CC_PLUM \aC\\aC DDIGIT_CC_CHARTREUSE \aD\\aD DDIGIT_CC_POWDERBLUE \aE\\aE DDIGIT_CC_GOLD \aF\\aF DDIGIT_CC_GAINSBORO \aG\\aG DDIGIT_CC_Y_0 \aH\\aH DDIGIT_CC_Y_1 \aI\\aI DDIGIT_CC_Y_2 \aJ\\aJ DDIGIT_CC_Y_3 \aK\\aK DDIGIT_CC_Y_4 \aL\\aL DDIGIT_CC_Y_5 \aM\\aM DDIGIT_CC_Y_6 \aN\\aN DDIGIT_CC_Y_7 \aO\\aO DDIGIT_CC_Y_8 \aP\\aP DDIGIT_CC_Y_9 \aQ\\aQ DDIGIT_CC_Y_A \aR\\aR DDIGIT_CC_Y_B \aS\\aS DDIGIT_CC_Y_C \aT\\aT DDIGIT_CC_Y_D \aU\\aU DDIGIT_CC_Y_E \aV\\aV DDIGIT_CC_Y_F""" ALIGN = -1 # Horizontal Alignment. eg 1 or 2 or 3, As numeric keypad, -1 is AUTO align DELAY=100 ESC=2 # esc=2, ESC codes allowed in data strings, 1=not allowed MOD = RT_TxtQueryLines(S) * 20 + Height + DELAY Scriptclip(""" M=(current_frame % MOD) A=(ALIGN == -1) ? ((current_frame/MOD) % 3 + 1) : ALIGN RT_Subtitle("%s",S,align=A,y=height+DELAY-M,expy=true,esc=ESC) """) return last
__________________
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; 2nd February 2019 at 15:00. |
29th January 2019, 19:03 | #9 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Yanak, just pointing something out.
Code:
c=ColorBars d=BlankClip(height=20, color=$000000, length= c.FrameCount).ShowFrameNumber(scroll=false,offset=0,x=25/8,y=25/1.5,size=25,text_color=$ffffff).Subtitle("hello",y=-4,align=8,size=25,text_color=$ffffff) d.StackVertical(c).AudioDubEx(c) and in Avs v2.58 (which Im running at the moment, Y has to be int else error (x, and y went float in v2.60). So I guess that x and y need always be Round()'ed if compatibility a concern. (Float arg passed to a function expecting int will crash, int arg passed to a function expecting float will be accepted ok, and in v2.6 will actually be converted to a float).
__________________
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 ??? |
29th January 2019, 19:20 | #10 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Thanks for all the infos StainlessS, will serve one day for sure, i understand now why there is a difference, of course
Yeah this is a legacy code from a filter i made in Staxrip, so it auto adapts to the font size used and always align the text the closest to the screen corner position i select on screen, top right, top left, bottom left etc etc, this is the staxrip filter i created many moons ago for quick and easy way to add the frame displayed as text on the video: https://pastebin.com/FsrXH7jt Figured out what i was doing wrong and fixed the function i was trying to modify : Code:
Function TSub(clip c, string Tit, Bool "ShowFrameNo", Int "Col"){ BlankClip( c, height=20, Color=Default(Col,0)) (Default(ShowFrameNo,False))?ShowFrameNumber(scroll=false,offset=0,x=3,y=16,size=25,text_color=$ffffff) \ .Subtitle(Tit,y=-4,align=8,size=24,text_color=$ffffff) \ :Subtitle(Tit,y=-4,align=8,size=24,text_color=$ffffff) StackVertical(c) } colorbars.TSub("hello",true) Noticed that the more text you add in sub the slower it gets, this Code:
colorbars.TSub("hello hello hello hello hello hello",true) Code:
colorbars.TSub("hello this is a test for title to see speed impact",true) Last edited by Yanak; 29th January 2019 at 19:27. |
30th January 2019, 02:39 | #11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
TitleBar v1.01 Update. See first post.
Code:
colorbars #TSub("hello",false) # 4551 [x64 7598] #TSub("hello",true) # 1121 [x64 1296] #titlebar("hello",false) # 4546 [x64 7613] #titlebar("hello",True) # 4277 [x64 6851] Code:
AviSource("d:\g.avi") # YV12 #TSub("hello") # 750 [x64 936] #TSub("hello",true) # 469 [x64 520] #titlebar("hello",False) # 745 [x64 925] #titlebar("hello",True) # 744 [x64 910]
__________________
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 ??? |
30th January 2019, 06:21 | #12 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Yanak, here mod of your mod.
Code:
Function YanakSub(clip c, string Tit, Bool "ShowFrameNo", Int "Col"){ Function nDigits(Int n) { return Int(Log10(Max(n,1)))+1 } # Log10 v2.60+ [ Log10(n) = Log(n)/Log(10) ] ShowFrameNo=Default(ShowFrameNo,False) Y=16 XMUL=9.5 XOFF=2 # CONFIG-ISH stuff FC=c.FrameCount TitGapX=(ShowFrameNo) ? Max(nDigits(FC-1),5)*XMUL : 0 Tit=(ShowFrameNo) ? "] " + Tit : Tit c.BlankClip(Length=(ShowFrameNo)?FC:1,height=20, Color=Default(Col,0)).Subtitle(Tit,x=Round(TitGapX+Xoff),y=Y,align=4,size=18,text_color=$ffffff,Font="Courier New") (ShowFrameNo)?ShowFrameNumber(scroll=false,x=Xoff,y=Y,size=18,text_color=$ffffff,Font="Courier New"):NOP StackVertical(c).AudioDubEx(c) } TIMES=1000000 colorbars #.Trim(0,-1).Loop(TIMES,0,0) YanakSub("hello",True) Code:
colorbars #TSub("hello",false) # 4551 [x64 7598] {4555 : x64 7607} #TSub("hello",true) # 1121 [x64 1296] {1652 : x64 2015} Tried a little jiggery-pokery, write Title to frame with appropriate offset, and if writing frame number, do it top of that title frame. ShowFrameNumber is awkward in that it always shows 5 digits, until more digits required due to length, we can only write text for max digit length. Also, used Courier New fixed width font. EDIT: OOps, Damn, I meant to change default ShowFrameNo to False to match TSub, but think I must have toggled it twice, so is same as v1.00, will change again in next up, maybe later today. Might also change to DDigit text renderer, possible slight reduction in speed, but with multi-colored title possible.
__________________
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; 30th January 2019 at 16:15. |
30th January 2019, 18:27 | #13 | Link |
Registered User
Join Date: Oct 2011
Posts: 275
|
Tied the new dll, it goes fast, very fast, 17794 FPS when set to false and 15531 FPS when set to true.
( tried to compile it myself too, no gain with false, probably hitting my hardware limits here, but gaining an extra 500 FPS when it is set to true, passing to 16036 FPS ) Tried the mod of the moded function, it is faster than my first poor attempts, 4549 FPS when set to true vs 4261 FPS before on my attempt, good gain you got there too, and yes it displays all the digits with all the zero's, does not bother me much as I'm used to it but won't mind if one day it changes and displays only the digits needed and expand dynamically, sadly avisynth is quite limited when it comes to subtitles and stuff like this for printing text on screen, one can only dream it can one day expand to match some of the options FFmpeg offers like drawbox i asked about once in the forum. Tried also a variation with avisynth native function "blackness" instead of "blankclip" on my function yesterday, gained a few fps doing this, just a few, but with the dll being that fast it ain't worth it to spend more time on this i guess As always amazing job from your part Last edited by Yanak; 3rd February 2019 at 04:28. |
4th February 2019, 02:18 | #14 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
TitleBar v1.02, update see first post. [EDIT: Switched from Info.H text renderer to DDigit with color capability]
Doc in brief Code:
Plugin's for both Avisynth v2.58 and v2.6 (avs+ x86 & x64). Filter to Add a 20 pixel Black[or colored] TitleBar to top of clip, and to write a title string and optional Frame Number to each frame. Uses DDigit text renderer & where showing FrameNumber, does not require ScriptClip() filter call. Titlebar(clip c,String "Tit"="",Bool "ShowFrameNo"=False,Int "Col"=$000000,String "ColChr"="",Bool "Esc"=True) Tit, Default "", Title string to write above video clip to the TitleBar. The Tit title string may also contain Escape codes if Esc Arg is True, see later. ShowFrameNo, Default FALSE. If True, then also writes Frame Number as in eg "1234] My Title String". Col, Default $000000. RGB color of the TitleBar background. ColChr, Default "" (Starting Color = default). A single character as a string which sets the Starting color used for printing the FrameNumber/Title text. If the ColChr string contains more than a single character, it will throw an error. Valid single character can be any one of these (upper or lower case):- "0123456789ABCDEF" # 16 Color character codes '0' to 'F' "GHIJKLMNOPQRSTUV" # 16 Greyscale character codes in ascending order of lightness 'G' to 'V' ($00 -> $FF) "-!*" # 3 Specials, # '-' = Default color. : As '7' [White] in Color colorspace : As 'S' [Near white $CC] in Y8. # '!' = HiLite color. : As 'A' [Orange] in Color colorspace : As 'V' [White $FF] in Y8. # '*' = Silently converted to '-', ie Default color. (Only has real meaning embedded in the Tit title string). Esc, Default True. If True, then Escape codes "\a?", and "\x??" can be used to embed data into Tit Title string (The 'a' and 'x' MUST BE LOWERCASE). Where "\a?", '?' is any character valid as in above ColChr, enables changing color on title bar, within the Tit title string. In such a case, "\a*" switches to the OnEntry or Starting color, ie same color as set via ColChr. Where "\x??", each '?' character MUST BE an UPPERCASE hex digit '0' -> 'F'. Enables embedding 8 bit Hex character code into the Tit title string. You can use eg "\\x00" to embed a literal sequence of "\x00" into the title string, ie "\\" embeds a single backslash and so does not interpret as hex insertion code. Use similar to avoid color escape code eg "\\a-" to embed literal "\a-". Esc=False, does NOT process color Escape codes nor Hex insertion Escape code. NOTE, the only character in range 0->31 that can be used in Tit title string is BEL [chr(7)] (where "\a" is converted to BEL color switch code), all other codes in range 0->31 (eg chr(9) TAB) are converted to SPACE character. Also, CarriageReturn(13) and Newline(10) will terminate the title string early, eg you cannot use Newline(10) to print on the input clip [neither as "\n" nor Chr(10)]. Likewise, characters $E0 -> $FF will be converted to SPACE character (they also do not exist in font). Code:
ColorBars(width=1024) # Chr(137) [$89]is Copyright symbol (c). SHOWFRAMENO = true COLCHR = "!" # Hilite Code (takes effect from FrameNumber if ShowFrameNumber=True, Else takes effect on Tit title string) ESC = True Titlebar("Title\aDBar \a-\x89 \a2S\a3t\a4a\a5i\a6n\a8l\a9e\aAs\aBs\aCS \a*2019",ShowFrameNo=SHOWFRAMENO,ColChr=COLCHR,Esc=ESC) EDIT: And with ESC switched to false EDIT: Code:
#titlebar("hello",false) # 4546 x64 7613] NEW{4463 x64 7456} # numbers are FPS on colorBars [Core 2 Quad Q9550 @ 2.83GHz] #titlebar("hello",True) # 4277 x64 6851] NEW{4377 x64 7179}
__________________
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; 5th February 2019 at 06:28. |
5th February 2019, 06:43 | #15 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Grouchy,
Would you prefer omission of the ']' with frame number, I could perhaps make it so that Title butts up hard again the frame number, so as to make "] " optional, would require eg FrameNo="1234" & Tit ="] Some title text" to achieve same style as current, but is then more configurable for the user. (however, may be a bit more awkward in cases where ShowFrameNo may be toggled on/off in stacked multi-window arrangement [eg show FrameNo only on Top/LHS Frame], "] " would also need toggled addition to Title). Thoughts ?
__________________
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 ??? |
5th February 2019, 09:16 | #16 | Link |
Registered User
Join Date: Dec 2008
Posts: 589
|
Wouldn't there be an incredibly tiny benefit to use 24 vertical lines by default instead of 20, so that you have a multiple of 8 vertically? Maybe it would help compression by a super tiny small amount, if the codec uses 8x8 blocks or something like that.
What's the reasoning for using 20 as default? If you use a monospace by default, you could also hardcode the characters in the ASCII table as an array of bytes, 12 x 24 bits per character or something like that, so you would just copy bytes over. See fonts like https://fonts.google.com/specimen/Source+Code+Pro or https://fonts.google.com/specimen/Roboto+Mono Also maybe you could implement some basic xml/html tags like <em> <strong> <b> if you think it would be worth it... though would be a bit silly to support attributes like <span style="color:red;background:black;"> maybe deviate from that and do something like <red></red> or any 6-8 hexadecimal tag as color (2 optional digits for alpha blending?) edit: checked the source code (why don't you put the dll's in a "binary" folder and source code in "src" or whatever) and the font seems to be hardcoded, well just 32..223 codes ... so shouldn't be a problem to change the array with better font or add effects. Last edited by mariush; 5th February 2019 at 10:13. |
5th February 2019, 11:31 | #17 | Link | ||||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Was only anticipating use of TitleBar() for temp (maybe in stacked window) display, did not at all consider anybody wanting to save/encode output. Could easily add a Y offset of 2 pixels to center titles, with height = 24, would anybody really want this [save output] ? Quote:
Had not envisaged spending much time on this at all, started coding it at about 13:30 PM, posted at just before 19:00 PM on same day. Quote:
I would not even consider trying to create my own (tried that once on Sinclair QL where 3x5 font [EDIT: excluding spacing], was a horrible experience, similar style font to Wonkey_Monkey font in PixelScope:- https://forum.doom9.org/showthread.php?p=1849850). Directory of last supplied zip:- Code:
titlebar_25&26_x86_x64_dll_v1.02_20190204\ avisynth_25\ titlebar_25.dll avisynth+_x86\ titlebar_x86.dll avisynth+_x64\ titlebar_x64.dll avs\ !!! requires rt_stats !!! titlebar_characterset.avs titlebartest.avs showcolorcodes.avs source\ titlebar.suo titlebar.sln # <<<<<<<<<<< Click me and then click Menu/Build/Batch Build compiling_readme.txt titlebar_25\ titlebar_25.vcproj titlebar_25.suo titlebar_25.sln titlebar\ titlebar.vcproj titlebar.suo titlebar.sln src\ version.h titlebar.cpp resource.rc resource.h gpl.txt ddigit.txt ddigit.h ddigit.cpp # <<<<<<<< Info.h font lives here (renamed so as to be able to include Info.h in same source [I know nothing of namespace's, and dont care]) compiler.h avisynth25.h avisynth.h titlebar.txt still burdened with about a half dozen bugs, some of which produced access violations and caused my (and other peoples) plugins to crash. [A small clip size would cause access violation when text wrapped off bottom of frame, also if small width then would horizontal wrap and overprint previously printed text, also RGB started printing 1 raster line above top of RGB clip[where possible access violation], and extended ASCII characters over dec 127, never printed correctly (where signed char) and usually produced hieroglyphics style nonsense [and possible access violation] when accessing bytes prior to font array. + more bugs. Was also real slow (prior to IanB refactoring)]. EDIT: Many plugins probably still suffer from above problems where using OLD Info.h metrics. EDIT: Not sure which, either RemoveBlend or ReverseBlend[<<<probably this one] required a minimum height of about 480 pixels to not crash when showing metrics, I tended to stack a couple of clip instances vertical to be able to use it without problems, and then crop. Quote:
__________________
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; 6th February 2019 at 01:30. |
||||
Thread Tools | Search this Thread |
Display Modes | |
|
|