PDA

View Full Version : filename inserted into subtitle script?


perthmetro
13th March 2006, 14:20
is there a script that can insert the avi filename as a subtitle... for example if the filename is "2006-03-23 My Movie.avi" then it generates a subtitle of the same name without the file extension.

Thanks, Pete

stickboy
13th March 2006, 20:55
Well, basically you could do something like:
function FindStrR(string s, string t)
{
index = FindStr(RevStr(s), RevStr(t)) - 1
return (index == -1) ? 0
\ : StrLen(s) - StrLen(t) - index + 1
}


function LabeledAVISource(string filename)
{
offset = FindStrR(filename, ".")
Assert(offset != 0)
return AVISource(filename).Subtitle(LeftStr(filename, offset - 1))
}

perthmetro
14th March 2006, 12:28
thanks so much for that... sorry about this but i'm a real newbie at this... how do i exactly get this code to work?

thanks again

Pete

PS whilst I've got a good helper here :) could you also this question?...

Is there a way I can load an avisynth script AND my VD processor settings (.vcf) from one file?

for example... I want to load an avisynth subtitle script AND my set of VD filters (ctrl+L) in as least amount of clicks as possible.

Thanks heaps,

Pete

stickboy
17th March 2006, 03:15
Simply copy and paste it into your script, and instead of using AVISource("someFile.avi"), use LabeledAVISource("someFile.avi").

perthmetro
17th March 2006, 16:31
Thanks again for that, you've been a geat help. I got it working. However it produces the whole file path rather than just the filename... can this be fixed? TIA. This is my script... As you can see the current file path is very long. If there is a way to just have the 2006-03-13 0945 Angus 11 part then it would make it perfect.

filename = "C:\Documents and Settings\Pete and Angus\My Documents\My Videos\To be processed\2006-03-13 0945 Angus 11.avi"

LabeledAVISource(filename)

function FindStrR(string s, string t)
{
index = FindStr(RevStr(s), RevStr(t)) - 1
return (index == -1) ? 0
\ : StrLen(s) - StrLen(t) - index + 1
}


function LabeledAVISource(string filename)
{
offset = FindStrR(filename, ".")
Assert(offset != 0)
return AVISource(filename).Subtitle(align=3,font="arial",size=15, text_color=$ffffff, LeftStr(filename, offset - 1))
}

Subtitle(align=8,font="arial", size=15, text_color=$ffffff, GetFileInfo(filename, "creationTime"))

perthmetro
17th March 2006, 16:33
Thanks again for that, you've been a geat help. I got it working. However it produces the whole file path rather than just the filename... can this be fixed? TIA. This is my script... As you can see the current file path is very long. If there is a way to just have the 2006-03-13 0945 Angus 11 part then it would make it perfect.

filename = "C:\Documents and Settings\Pete and Angus\My Documents\My Videos\To be processed\2006-03-13 0945 Angus 11.avi"

LabeledAVISource(filename)

function FindStrR(string s, string t)
{
index = FindStr(RevStr(s), RevStr(t)) - 1
return (index == -1) ? 0
\ : StrLen(s) - StrLen(t) - index + 1
}


function LabeledAVISource(string filename)
{
offset = FindStrR(filename, ".")
Assert(offset != 0)
return AVISource(filename).Subtitle(align=3,font="arial",size=15, text_color=$ffffff, LeftStr(filename, offset - 1))
}

Subtitle(align=8,font="arial", size=15, text_color=$ffffff, GetFileInfo(filename, "creationTime"))

stickboy
18th March 2006, 20:27
Okay, try this instead:

function FindStrR(string s, string t)
{
index = FindStr(RevStr(s), RevStr(t)) - 1
return (index == -1) ? 0
\ : StrLen(s) - StrLen(t) - index + 1
}


function LabeledAVISource(string filename)
{
baseOffset = FindStrR(filename, "\")
baseOffset = baseOffset != 0 ? baseOffset : FindStrR(filename, "/")
extOffset = FindStrR(filename, ".")
Assert(extOffset != 0)
AVISource(filename)
Subtitle(MidStr(filename, baseOffset + 1, extOffset - 1))
return last
}

Edit: Oops. Bug fixed.

perthmetro
19th March 2006, 04:23
thanks, but... still the same, has the whole file path as the subtitle.

I was thinking of another way???... is it easier enough to extract the filename from the movie, and place it into a certain position in a .ssa text file?

thanks for you (ongoing) help

Pete

stickboy
19th March 2006, 11:20
Oops. I accidentally used FindStr instead of FindStrR. I updated the script above.

perthmetro
19th March 2006, 14:53
Perfect, thanks for that. It works a treat.

You're gonna hate me for this but... do you know how to incorporate this into my Virtualdub .vcf process settings so that it applies to the movie file currently loaded in VD? I know to to include a avisynth script for a specific file within the script (like this script), but can it be done to any file that is loaded into VD... am i making sense? At the moment if I want to incorporate your great script you made me into more than one file I will need to either change the file name one by one or do the batch script thing. I'd like to be able to apply your script to the movie file currently on VD.

Thanks again in any case I'll be using this heaps...

Pete

perthmetro
14th June 2007, 20:10
anyone know how to do this?

stickboy
14th June 2007, 20:39
Doesn't sound possible.

perthmetro
16th June 2007, 05:54
could i insert this script in autogk (autogk uses avisynth doesn't it?) somehow so that all the movies i convert have their filename as a subtitle?