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 6th October 2016, 09:26   #1  |  Link
hristoff2
Registered User
 
Join Date: Jun 2007
Posts: 39
How to display "" using Avisynth? Matrix grid comparison of videos

Hey,

I'm working with high speed videos and need / want to do side by side comparisons or matrix-grid comparisons.

I made a counter to display the runtime and two versions of how to compare several videos in a matrix grid. Everything works fine, except this

subtitle(mm+" s", text_color=color, size=size, x=x, y=y)



returns an A with hat as in in front of the . Videos are only a few hundred frames at 210000 kHz, meaning 4.7ish s per frame. How can I fix this?

The weird thing is, that this is displayed correctly, so it must be related to "subtitle_framerate.avs":

Code:
FFVideoSource("testclip.avi")
Subtitle("test ",x=10,y=6,size=sz,text_color=clr)




Here is the rest of the code:

Code:
##subtitle_framerate.avs
## Written by djcj
## Modified by h2
## Last change: Oct 5th 2016

function flowtime(clip last, string "mode", int "color", float "size", int "x", int "y") {
mode = Default(mode, "error")
global color = Default(color, $ffffff)
global size = size
global x = x
global y = y

/*
mode =

hmmss: 0:04:17
mmss: 04:17
Hz210000:  1 Frame = 4,762 s

*/

# h:mm:ss
error = ScriptClip("""
subtitle("specify framerate in format (xyzkHz)", text_color=color, size=size, x=x, y=y)
""")

# h:mm:ss
hmmss = ScriptClip("""
fs = current_frame/framerate
h = string(floor((fs/60)*60)/3600, "%1.0f")
mm = string(floor(fs/60)-floor(fs/3600)*60, "%02.0f")
ss = LeftStr(string(fs-floor(fs/60)*60, "%06.3f"), 2)
subtitle(h+":"+mm+":"+ss, text_color=color, size=size, x=x, y=y)
""")

# mm:ss, Platzhalter und Vorlage fr Makro Videos -- dafuer geht aber auch ShowTime()
mmss = ScriptClip("""
fs = current_frame/framerate
mm = string(floor(fs/60)-floor(fs/3600)*60, "%02.0f")
ss = LeftStr(string(fs-floor(fs/60)*60, "%06.3f"), 2)
subtitle(mm+":"+ss, text_color=color, size=size, x=x, y=y)
""")

# 210kHz...beliebig erweitern
Hz210000 = ScriptClip("""
fs = 4.762*current_frame
mm = string(fs, "%1.2f")
subtitle(mm+" s", text_color=color, size=size, x=x, y=y)
""")


(mode=="hmmss") ? Eval("""
	return hmmss
""") : \ 
(mode=="mmss") ? Eval("""
	return mmss
""") : \ 
(mode=="Hz210000") ? Eval("""
	return Hz210000
""") : \ 
	  Eval("""
	return error
""")
}
And I display it in a matrix grid and some descriptions using avslib with

Code:
#LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")
Import("subtitle_framerate.avs")

# load required modules (requires AvsLIB)

LoadModule("avslib", "array", "core")
LoadModule("avslib", "filters", "stack")

#Jetzt gehts los

sz = 16
clr = $ffffff

a= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)

b= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)

c= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)

d= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)

e= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)

f= FFVideoSource("testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr).\
flowtime(mode="Hz210000",size=20,x=10,y=132)



#StackVertical(StackHorizontal(a, b),StackHorizontal(c,d))


#mit LoadModule AvsLib gehts
vids = ArrayCreate(a,b,c,d,e,f)
return Stack(vids, 2, 3)
or without AvsLib

Code:
#LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")
Import("subtitle_framerate.avs")

# load required modules

#LoadModule("avslib", "array", "core")
#LoadModule("avslib", "filters", "stack")

#Jetzt gehts los

sz = 16
clr = $ffffff

a= FFVideoSource("E:\zzzzzzzzzz_avisynth\testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr)

b= FFVideoSource("E:\zzzzzzzzzz_avisynth\testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr)\

c= FFVideoSource("E:\zzzzzzzzzz_avisynth\testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr)

d= FFVideoSource("E:\zzzzzzzzzz_avisynth\testclip.avi").\
AddBorders(6,6,6,6).\
Subtitle("text1",x=10,y=6,size=sz,text_color=clr).\
Subtitle("text2",x=10,y=24,size=sz,text_color=clr)

StackVertical(StackHorizontal(a, b),StackHorizontal(c,d))
flowtime(mode="Hz210000",size=20,x=16,y=316)
hristoff2 is offline   Reply With Quote
Old 6th October 2016, 10:00   #2  |  Link
Groucho2004
Cranky Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,571
Quote:
Originally Posted by hristoff2 View Post
returns an A with hat as in in front of the .
That's what the "" character looks like when you save the script with UTF-8 character encoding. Save it in 8 bit ANSI, CP 1252, for example.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 6th October 2016, 11:52   #3  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
Chr(181) should do it even with a Unicode script file, but watch out:
Quote:
http://avisynth.nl/index.php/Internal_functions#Chr

Note that characters above the ASCII character set (ie above 127) are code page dependent and may render different (visual) results in different systems.
raffriff42 is offline   Reply With Quote
Old 6th October 2016, 12:44   #4  |  Link
Groucho2004
Cranky Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,571
Quote:
Originally Posted by raffriff42 View Post
Chr(181) should do it even with a Unicode script file
Huh? Avisynth does not accept UTF-16 or UTF-8 characters. It has to be ANSI 8 bit encoding in one of the standard Windows code pages (and of course the system locale should match that code page).
Also, if Avisynth finds a UTF-16 or UTF-8 BOM it will throw an error right away.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 6th October 2016, 12:55   #5  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
OK I see what you are saying

Last edited by raffriff42; 6th October 2016 at 13:02.
raffriff42 is offline   Reply With Quote
Old 6th October 2016, 15:46   #6  |  Link
hristoff2
Registered User
 
Join Date: Jun 2007
Posts: 39
Mh, converting with Notepad++ to ANSI fixed it, now I feel stupid - thanks a lot!

While we're at it, any way to define this globally, like this (pseudo code):


AddBorders(6,6,6,6)

-->

borders = 6,6,6,6

Addborders(string(borders)) or Addborders(borders)

tried variations of that, but it didn't work

If I want to do stuff like that, do I have to write it as a plugin and call it from my actual .avs script or can I somehow write subroutines in my actual avs script?
hristoff2 is offline   Reply With Quote
Old 6th October 2016, 16:24   #7  |  Link
Groucho2004
Cranky Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,571
Quote:
Originally Posted by hristoff2 View Post
While we're at it, any way to define this globally, like this (pseudo code):


AddBorders(6,6,6,6)

-->

borders = 6,6,6,6

Addborders(string(borders)) or Addborders(borders)

tried variations of that, but it didn't work

If I want to do stuff like that, do I have to write it as a plugin and call it from my actual .avs script or can I somehow write subroutines in my actual avs script?
Frequently used stuff like that is probably best kept in a function within a .avsi in your auto-load directory. For example:
Code:
function AddBorders6(clip video)
{
 return video.AddBorders(6,6,6,6)
}
or more versatile:
Code:
function AddBordersN(clip video, int "m")
{
 m = default(m, 0)
 return video.AddBorders(m,m,m,m)
}
__________________
Groucho's Avisynth Stuff

Last edited by Groucho2004; 6th October 2016 at 16:30.
Groucho2004 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 19:04.


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