joshbm
24th September 2004, 05:04
I don't know whether this will be an uneventful thread or a useful thread. I was thinking back to all the little functions I use to manipulate strings and such, nothing to really do with any hard-core coding/deinterlacing or frame manipulation. I think it would be cool for people to share their own certain scripts for string, colorspace, etc manipulation. For example here are some of the scripts I use, some of which created:
function ColorSpace(clip a)
{
return
\ (IsYUY2(a)==true) ? "YUY2" :
\ (IsYV12(a)==true) ? "YV12" :
\ (IsRGB24(a)==true) ? "RGB24" :
\ (IsRGB32(a)==true) ? "RGB32" :
\ (IsRGB(a)==true) ? "RGB" : "YUV"
}
function ConvertTo(clip a, string colorspace, bool "interlaced")
{
inter=default(interlaced,false)
colorspace=UCase(colorspace)
return
\ (colorspace=="YUY2" ) ? a.ConvertToYUY2(interlaced=inter) :
\ (colorspace=="YV12" ) ? a.ConvertToYV12(interlaced=inter) :
\ (colorspace=="RGB24") ? a.ConvertToRGB24(interlaced=inter) :
\ (colorspace=="RGB32") ? a.ConvertToRGB32(interlaced=inter) :
\ (colorspace=="RGB" ) ? a.ConvertToRGB(interlaced=inter) : a
}
function TimeCode(clip a, string timecode, float "fps")
{
fps=default(fps,a.framerate)
hours=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps*60*60)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
minutes=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps*60)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
seconds=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
frames=int(Value(timecode))
return hours+minutes+seconds+frames
}
function FOrder(clip a)
{
return getparity(a) ? 1 : 0
}
function AddBlack(clip a, string "time", int "frames")
{
time=default(time,"00:00:01:00")
frames=default(frames,0)
olength=(frames>0) ? frames : a.TimeCode(time)
return (a.AddAudio()+BlankClip(pixel_type=a.ColorSpace,
\ length=olength
\,width=a.width,height=a.height,fps=a.framerate)).AddAudio()
}
function AddAudio(clip v1) {
v2 = Blankclip()
v1 = AudioDub(v1,v2)
return v1
}
The TimeCode one I have found most useful, because I work a lot with Ulead Media Studio Pro and within there I can see the starting and ending point in H:M:S:f. So it just makes sense to create a script which you can input those parameters and is converted to frame numbers.
ex.
Trim( TimeCode("00:00:26:21") , TimeCode("00:00:33:11") )
# >>> Same as Trim(800,1000) with 29.97fps video
Also I have found ColorSpace() useful to yield a string with the colorspace. Then I can store that in a variable and convert back to the original colorspace using ConvertTo().
Also FOrder() to find the field order of a clip as well as AddAudio() to add audio (due to the fact that I use DV Type I and need audio in order to import the avs file). I also created AddBlack(), so it will autodetect parameters for the input video file, instead of manually typing in the colorspace and width.
Just some quick scripts to start,
Josh
function ColorSpace(clip a)
{
return
\ (IsYUY2(a)==true) ? "YUY2" :
\ (IsYV12(a)==true) ? "YV12" :
\ (IsRGB24(a)==true) ? "RGB24" :
\ (IsRGB32(a)==true) ? "RGB32" :
\ (IsRGB(a)==true) ? "RGB" : "YUV"
}
function ConvertTo(clip a, string colorspace, bool "interlaced")
{
inter=default(interlaced,false)
colorspace=UCase(colorspace)
return
\ (colorspace=="YUY2" ) ? a.ConvertToYUY2(interlaced=inter) :
\ (colorspace=="YV12" ) ? a.ConvertToYV12(interlaced=inter) :
\ (colorspace=="RGB24") ? a.ConvertToRGB24(interlaced=inter) :
\ (colorspace=="RGB32") ? a.ConvertToRGB32(interlaced=inter) :
\ (colorspace=="RGB" ) ? a.ConvertToRGB(interlaced=inter) : a
}
function TimeCode(clip a, string timecode, float "fps")
{
fps=default(fps,a.framerate)
hours=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps*60*60)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
minutes=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps*60)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
seconds=round(int(Value(LeftStr(timecode,FindStr(timecode,":")-1)))*fps)
timecode=RightStr(timecode,StrLen(timecode)-FindStr(timecode,":"))
frames=int(Value(timecode))
return hours+minutes+seconds+frames
}
function FOrder(clip a)
{
return getparity(a) ? 1 : 0
}
function AddBlack(clip a, string "time", int "frames")
{
time=default(time,"00:00:01:00")
frames=default(frames,0)
olength=(frames>0) ? frames : a.TimeCode(time)
return (a.AddAudio()+BlankClip(pixel_type=a.ColorSpace,
\ length=olength
\,width=a.width,height=a.height,fps=a.framerate)).AddAudio()
}
function AddAudio(clip v1) {
v2 = Blankclip()
v1 = AudioDub(v1,v2)
return v1
}
The TimeCode one I have found most useful, because I work a lot with Ulead Media Studio Pro and within there I can see the starting and ending point in H:M:S:f. So it just makes sense to create a script which you can input those parameters and is converted to frame numbers.
ex.
Trim( TimeCode("00:00:26:21") , TimeCode("00:00:33:11") )
# >>> Same as Trim(800,1000) with 29.97fps video
Also I have found ColorSpace() useful to yield a string with the colorspace. Then I can store that in a variable and convert back to the original colorspace using ConvertTo().
Also FOrder() to find the field order of a clip as well as AddAudio() to add audio (due to the fact that I use DV Type I and need audio in order to import the avs file). I also created AddBlack(), so it will autodetect parameters for the input video file, instead of manually typing in the colorspace and width.
Just some quick scripts to start,
Josh