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 8th January 2014, 05:00   #1  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Get filename from Clip?

How can i return the filename of a clip?
for example to turn:

Avisource("hello.avi")
to
hello
zerowalker is offline   Reply With Quote
Old 8th January 2014, 05:10   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,923
Mutate your thinking:

stream="hello.avi"
AviSource(stream)

Now you have the name in a variable as you need.
Guest is offline   Reply With Quote
Old 8th January 2014, 05:12   #3  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
True, but i am trying to make a function that only makes use of the clip, else i would simply copy paste the file name and be done with it.
zerowalker is offline   Reply With Quote
Old 8th January 2014, 05:43   #4  |  Link
TurboPascal7
Registered User
 
TurboPascal7's Avatar
 
Join Date: Jan 2010
Posts: 270
If you want something like:
Code:
function get_filename(clip c) { return some_way_to_get_the_filename(c) }
Give up. Unless the source filter you're using sets the filename as some global variable, you can't get it.
Why do you need this?
__________________
Me on GitHub | AviSynth+ - the (dead) future of AviSynth
TurboPascal7 is offline   Reply With Quote
Old 8th January 2014, 05:46   #5  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Well pretty much thatīs what i am trying to do.
Damn, thought it should be someway, i know how to get the script name and path through an error message,
and tried to find a way to make the avisource spit out an exception with the filename without luck.

I want it for simplicity, i am doing a function where i am retrieving date and time from the filename, and i donīt want to copy paste the filename each time, simply writing the function would do all the work.
zerowalker is offline   Reply With Quote
Old 8th January 2014, 06:17   #6  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
Quote:
Originally Posted by zerowalker View Post
i know how to get the script name and path through an error message
Actually, since 2.6, the error-method is not needed.
http://avisynth.nl/index.php/Interna...ript_functions
vampiredom is offline   Reply With Quote
Old 8th January 2014, 06:27   #7  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Oh, well thatīs good.
hmm, is Avisource an internal function?
Meaning, i would have to ask an Avisynth developer to add "filename" variable?
zerowalker is offline   Reply With Quote
Old 8th January 2014, 06:36   #8  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
Quote:
Meaning, i would have to ask an Avisynth developer to add "filename" variable?
I do not think all that is really needed or advisable. Could you post your script? That might make it easier for someone to give you more specific advice on how you can do what you are trying to do.
vampiredom is offline   Reply With Quote
Old 8th January 2014, 06:53   #9  |  Link
innocenat
Registered User
 
innocenat's Avatar
 
Join Date: Dec 2011
Posts: 77
What happen when people pass you BlankClip? ColorBar? StackHorizontal? Overlay?
innocenat is offline   Reply With Quote
Old 8th January 2014, 07:07   #10  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,923
Quote:
Originally Posted by innocenat View Post
What happen when people pass you BlankClip? ColorBar? StackHorizontal? Overlay?
Then it outputs BlankClip, ColorBar, StackHorizontal, or Overlay.
Guest is offline   Reply With Quote
Old 8th January 2014, 07:17   #11  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
You know, not that it is remotely practical but ... you COULD encode the filename's chars into numeric values, then store these values as pixels in extra lines in the video then parse them back.
vampiredom is offline   Reply With Quote
Old 8th January 2014, 08:01   #12  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Here is the Script (Currently made so i have to write the filename as a string).

Quote:
function TimeStamp(clip a,string filename,int DisplayTime)
{

err_msg=filename
filename3=RightStr(err_msg, FindStr(RevStr(err_msg), "\")-1)
#~ Blankclip(100).Subtitle(RightStr(filename3, 100), x=8, y=0, first_frame=0,font="Arial", size=18, text_color=$FFFF00, halo_color=$000000, align=7, spc=0, font_width=0.0, font_angle=0.0, interlaced=False)
gettime = RightStr(filename3,16)
time2 = LeftStr(gettime, StrLen(gettime) - 14)+":"+LeftStr(gettime, StrLen(gettime) - 11).RightStr(2)+":" +RightStr(gettime, StrLen(gettime) -6 ).LeftStr( StrLen(gettime)-14 )+":"
ms=Round(value(RightStr(filename3,7).LeftStr(3)))
date=RightStr(filename3, 27).LeftStr( StrLen(filename3)-27 )+"*"
framel=Ceil(FrameCount(a)*(1000/FrameRate(a)))+ms*2

#~ Blankclip(100).Subtitle(ms, x=8, y=0, first_frame=0,font="Arial", size=18, text_color=$FFFF00, halo_color=$000000, align=7, spc=0, font_width=0.0, font_angle=0.0, interlaced=False)

BlankClip(length=framel, width=344, height=50, pixel_type="YV12", fps=1000, fps_denominator=1, audio_rate=48000, channels=2, sample_type="16bit", color=$000000)
ShowSMPTE(offset=time2.RightStr( 10)+"00", font="Digital-7 Mono",x=90,y=22, size=32, text_color=$FFFFFF, halo_color=$000000, font_width=0.0, font_angle=0.0)
Subtitle(date, x=0, y=22, font="Digital-7 Mono", size=32, text_color=$FFFFFF, halo_color=$000000, align=7, spc=0, font_width=0.0, font_angle=0.0, interlaced=False)
Trim(ms,0).ShowTime(x=254,y=48,offset_f=0, font="Digital-7 Mono", size=32, text_color=$FFFFFF, halo_color=$000000, font_width=0.0, font_angle=0.0).ChangeFPS(30, linear=false)
c=last

DisplayTime <= 0 ? Eval("""
over=Overlay(a,c, x=10, y=10, opacity=1.0, mode="blend")
over.Subtitle(filename, x=400, y=5, first_frame=0,last_frame=300, font="Arial", size=35, text_color=$FFFF00, halo_color=$000000, align=7) ++ a.Trim(framecount(over),0)
""") : Eval("""
over=Overlay(a,c, x=10, y=10, opacity=1.0, mode="blend").Trim(0,Round((FrameRate(a)*DisplayTime)))
over.Subtitle(filename, x=400, y=5, first_frame=0, font="Arial", size=35, text_color=$FFFF00, halo_color=$000000, align=7) ++ a.Trim(framecount(over),0)
""")
}
EDIT:

The filename is supposed to be, X:\2013-12-22 00-41-10-168.xxx , you can have it in as much folders as you like, but it wonīt work with just the filename, it needs a path as well (as itīs how i currently made it).

Last edited by zerowalker; 8th January 2014 at 08:06.
zerowalker is offline   Reply With Quote
Old 8th January 2014, 09:31   #13  |  Link
ultim
AVS+ Dev
 
ultim's Avatar
 
Join Date: Aug 2013
Posts: 359
Quote:
Originally Posted by vampiredom View Post
You know, not that it is remotely practical but ... you COULD encode the filename's chars into numeric values, then store these values as pixels in extra lines in the video then parse them back.
Actually, there already are plugins using that approach to pass colorimetry hints. Not that I recommend it though. Obvious downsides are 1) complexity, 2) being destructive to the video (even if probably unnoticably), and 3) that no filter must be present that change pixels between such plugins, as they will destroy the information in the pixels.

IMHO, just use special variables (with well-distinguished names to avoid conflicts) for information passing. This approach is ofc also not perfect, like being unable to use the same variable for multiple clips with different property value. Hopefully avs+ will solve this in the future.
__________________
AviSynth+
ultim is offline   Reply With Quote
Old 9th January 2014, 02:03   #14  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Okay i will ask the Developers, donīt think anyone actually cares, but i canīt see the hurt in adding one variable to Avisource, better ask than not i guess.


ultim: Wait, are you the Avisynth+ Developer?
If so, do you by any chance got time to add that function/variable, that just contains the filename and path?

Thanks
zerowalker is offline   Reply With Quote
Old 9th January 2014, 04:27   #15  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
Quote:
Originally Posted by zerowalker View Post
i canīt see the hurt in adding one variable to Avisource
You know, in concept, I do agree that being able to set custom clip properties would just about the handiest thing imaginable.

However, there would likewise be no harm (and a lot less complication) in you adding a filename parameter to your function ... and, unless I am misunderstanding something here, it looks like you already have.

Quote:
function TimeStamp(clip a,string filename,int DisplayTime)
Also, if a is a clip, where is that clip coming from? I'm afraid I may be missing the obvious but I do not see the issue.

Last edited by vampiredom; 9th January 2014 at 04:29.
vampiredom is offline   Reply With Quote
Old 9th January 2014, 04:29   #16  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
As you say, itīs 2 sides of the same coin or something.

Why i have added it in my function is because, itīs the only way.

But just writing: TimeStamp()
Would be much better.

I would gladly add it myself, but i am not a programmer of that caliber, we are talking extremely simple C# here.
Hence my option being to ask others, as shameful as it may be.
zerowalker is offline   Reply With Quote
Old 11th January 2014, 18:51   #17  |  Link
ultim
AVS+ Dev
 
ultim's Avatar
 
Join Date: Aug 2013
Posts: 359
Quote:
Originally Posted by zerowalker View Post
ultim: Wait, are you the Avisynth+ Developer?
If so, do you by any chance got time to add that function/variable, that just contains the filename and path?

Thanks
I would add it to Avs+, unfortunately I cannot because Avisynth(+) has no way to determine the source file name of a clip. From avisynth's point of view, frames of a clip just come from a blackbox (the filter), and only the filter knows where it gets its frames from. It is not an option to get the filename from the input arguments, because, likewise, Avisynth cannot know which argument contains the source filename - only the filter knows. There is a silent convention among filter developers that the first argument is the source file, but it actually does not need to be the case. Even if it were, Avs cannot really differentiate a source filter from a processing filter. And what if a source filter does not read from any file, like BlankClip?

So I cannot add such a variable that contains the source filename, because Avisynth itself honestly has no idea.

The only solution I see to this is if later new clip properties get added to clips. Then source filters could fill in the special property value that has the source path. But first this needs infrastructure support in Avs, which is planned but is currently totally missing, and after that all source filters will need to be modified to make use of this value.
__________________
AviSynth+
ultim is offline   Reply With Quote
Old 12th January 2014, 07:42   #18  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Ah, so it's not possible to just modify Avisource and be done with it, All source filters use the same "path" so to speak?

If so, well that explains the hardship, i thought it would be way easier, pretty much just well, add a variable in Avisource and link it to the "Path" and then tell Avisynth that it exists in just Avisource.
But nice that it's someway under work, i can surely wait if it is this much madness to get it.

I can still use String, even if it isn't optimal, it's more convenient then the current work to get it working from the way you speak.

Thanks
zerowalker is offline   Reply With Quote
Old 12th January 2014, 14:51   #19  |  Link
ultim
AVS+ Dev
 
ultim's Avatar
 
Join Date: Aug 2013
Posts: 359
Well, no, AviSource could be modified alone and then it would only work with AviSource. But without proper support in the core for clip properties, not even that would work correctly if you use multiple AviSource filters in the same script, so it wouldn't really be a step in the right direction. Also, the core should be free of filter-specific hacks.
__________________
AviSynth+
ultim is offline   Reply With Quote
Old 12th January 2014, 14:55   #20  |  Link
zerowalker
Registered User
 
Join Date: Jul 2011
Posts: 1,100
Ah, well it's better for it to be done properly from ground then to use hacks, as it's pretty useless if it only works in some scenarios with no real guideline.
zerowalker 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 04:52.


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