Display clip (file) name?
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
Display clip (file) name?
Hi.
I'm completely new to fusion. I would like to create a script of setting to get a file name, take a part of it and display it as lower 3drs.
Could you help me?
Cheers!
I'm completely new to fusion. I would like to create a script of setting to get a file name, take a part of it and display it as lower 3drs.
Could you help me?
Cheers!
- Midgardsormr
- Fusionator
- Posts: 1321
- Joined: Wed Nov 26, 2014 8:04 pm
- Location: Los Angeles, CA, USA
- Been thanked: 120 times
- Contact:
Re: Display clip (file) name?
This thread will get you started:
viewtopic.php?p=10922#p10922
Parsing the filename so you're not showing the entire path can be done with
In Andrew's example comp, the Text+ tool's Styled Text input has this expression:
which will show the full path of the current file. You can use
To break that down a little, working from inside to outside,
If you were doing this in a script, you'd probably assign variables for each piece, making it easier to read, but that's more difficult to do in a Simple Expression (not impossible, but probably more trouble than it's worth in this case).
viewtopic.php?p=10922#p10922
Parsing the filename so you're not showing the entire path can be done with
bmd.parseFilename()
, which is described in the scriptlib.lua file in your Scripts folder. For your convenience, here is the documentation from that file:Code: Select all
------------------------------------------------------------------------------
-- parseFilename()
--
-- this is a great function for ripping a filepath into little bits
-- returns a table with the following
--
-- FullPath : The raw, original path sent to the function
-- Path : The path, without filename
-- FullName : The name of the clip w\ extension
-- Name : The name without extension
-- CleanName: The name of the clip, without extension or sequence
-- SNum : The original sequence string, or "" if no sequence
-- Number : The sequence as a numeric value, or nil if no sequence
-- Extension: The raw extension of the clip
-- Padding : Amount of padding in the sequence, or nil if no sequence
-- UNC : A true or false value indicating whether the path is a UNC path or not
------------------------------------------------------------------------------
Text(self:GetSourceTool("MetadataSource").Output.Metadata.Filename)
which will show the full path of the current file. You can use
parseFilename()
to take just the part you want like so:Text(bmd.parseFilename(self:GetSourceTool("MetadataSource").Output.Metadata.Filename).CleanName)
To break that down a little, working from inside to outside,
self:GetSourceTool()
will return the tool connected to an input, in this case "MetadataSource"
, which is the name of the custom image input that was added to the Text+ tool. The tool that we get in this fashion is assumed to have a standard output called Output
, and you can read metadata off it, one field of which will be the filename. So we have someTool.Output.Metadata.Filename
, which returns the full path of the image. That is what you feed to parseFilename().CleanName
, which returns the CleanName field from the table described above. And, finally, Text()
returns a Text object that the Text+ tool can use.If you were doing this in a script, you'd probably assign variables for each piece, making it easier to read, but that's more difficult to do in a Simple Expression (not impossible, but probably more trouble than it's worth in this case).
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
Re: Display clip (file) name?
After trying many times different variations finally I've found the variation witch works for me:
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName
The ones in your example didn't work at all.
Now the question is - how to apply this comp to all clips in my timeline at once?
in text+ node the expression is : self:GetSourceTool("MetadataSource").ClipName
The ones in your example didn't work at all.
Now the question is - how to apply this comp to all clips in my timeline at once?
Re: Display clip (file) name?
You can try using resolve script API to import fusion comp onto every clip in timeline.Now the question is - how to apply this comp to all clips in my timeline at once?
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
- SirEdric
- Fusionator
- Posts: 2074
- Joined: Tue Aug 05, 2014 10:04 am
- Real name: Eric Westphal
- Been thanked: 162 times
- Contact:
- Midgardsormr
- Fusionator
- Posts: 1321
- Joined: Wed Nov 26, 2014 8:04 pm
- Location: Los Angeles, CA, USA
- Been thanked: 120 times
- Contact:
Re: Display clip (file) name?
MetadataSource is a user control on the Text+. That was set up in Andrew's thread that I linked to early on.
duofuan: Apologies that I didn't test what I suggested. I was on vacation and didn't have Fusion or Resolve available to me, so I was working entirely from memory. If I had noticed that this was posted in the Resolve forum, I'd have been more careful, since a MediaIn doesn't work the same way as a Loader, and you don't actually need to parse out the path. And now that I stop to think about it, I don't think a Simple Expression can access the scriptlib, anyway, so I failed on two counts. :/
I don't have a clue about working with Resolve's timeline, so I can't help you there, but I'm glad you at least got the first part of the puzzle solved!
- SirEdric
- Fusionator
- Posts: 2074
- Joined: Tue Aug 05, 2014 10:04 am
- Real name: Eric Westphal
- Been thanked: 162 times
- Contact:
Re: Display clip (file) name?
Ah! I see! Totally missed that one...Midgardsormr wrote: ↑Sun Jul 21, 2019 7:59 amMetadataSource is a user control on the Text+. That was set up in Andrew's thread that I linked to early on.

Re: Display clip (file) name?
For adding fu comps to timeline clips using python:
After instantiating a Resolve object. (I'm using "python_get_resolve")
This should do it:
After instantiating a Resolve object. (I'm using "python_get_resolve")
This should do it:
- from python_get_resolve import GetResolve
- resolve = GetResolve()
- projectManager = resolve.GetProjectManager()
- project = projectManager.GetCurrentProject()
- currentTimeline = project.GetCurrentTimeline()
- video1Clips = currentTimeline.GetItemsInTrack('video', 1)
- for key in video1Clips:
- video1Clips[key].ImportFusionComp('PATH TO COMP.comp')
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
Re: Display clip (file) name?
Thanks guys a lot for responses especially Iddos.
No problem Midgardsormr . After trials and errors slowly I'm getting there.
For a while I was out but now I have some time to try out the script.
One more (I figure simple) question is how to extract a part of a file name?
The result of expression self:GetSourceTool("MetadataSource").ClipName is a filename, in my case filenames are in format: 2018_05_31= 21_30_10.MP4
I was searching this on internet but without success. How can I adapt my expression above to get only date from filename like such: "2018-05-31" ?
What language is used for fusion expressions anyway? Is it lua?
No problem Midgardsormr . After trials and errors slowly I'm getting there.
For a while I was out but now I have some time to try out the script.
One more (I figure simple) question is how to extract a part of a file name?
The result of expression self:GetSourceTool("MetadataSource").ClipName is a filename, in my case filenames are in format: 2018_05_31= 21_30_10.MP4
I was searching this on internet but without success. How can I adapt my expression above to get only date from filename like such: "2018-05-31" ?
What language is used for fusion expressions anyway? Is it lua?
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
Re: Display clip (file) name?
So I'm making my steps forward.
I've found in Text+ properties on the tab with a cogwheel a lua script can be written into "Frame Render Script" field.
So after removing the expression from styled text field on "T" tab and pasting following lines int "Frame Render Script" :
varr = self:GetSourceTool("MetadataSource").ClipName
self.StyledText = varr
it works as is should.
Using string.gsub() function on any string works fine but strangely if I use it on varr variable it won't execute the script.
Is is because varr is not a string? Is there a way to convert it?
I'm confused
I've found in Text+ properties on the tab with a cogwheel a lua script can be written into "Frame Render Script" field.
So after removing the expression from styled text field on "T" tab and pasting following lines int "Frame Render Script" :
varr = self:GetSourceTool("MetadataSource").ClipName
self.StyledText = varr
it works as is should.
Using string.gsub() function on any string works fine but strangely if I use it on varr variable it won't execute the script.
Is is because varr is not a string? Is there a way to convert it?
I'm confused
- SirEdric
- Fusionator
- Posts: 2074
- Joined: Tue Aug 05, 2014 10:04 am
- Real name: Eric Westphal
- Been thanked: 162 times
- Contact:
Re: Display clip (file) name?
It should work when supplying an index:
varr = self:GetSourceTool("MetadataSource").Clip[1].Filename
- duofuan
- Posts: 16
- Joined: Sun May 27, 2018 3:18 am
Re: Display clip (file) name?
Sadly it doesn't work.
I found that the result of self:GetSourceTool("MetadataSource").ClipName is of type cdata.
Now I need to figure how to cast cdata object to string and I'm home
I found that the result of self:GetSourceTool("MetadataSource").ClipName is of type cdata.
Now I need to figure how to cast cdata object to string and I'm home