6
$\begingroup$

I was wondering whether it was possible to get the name of the Clip File of a Sequence via Python.

The current Sequence can be accessed via:

bpy.context.scene.sequence_editor.active_strip

I had a look at the Blender Python API, but did not find anything there.

EDIT: I guess I did not express myself quite clearly. My question is whether (and if so - how) it would be posssible to get the associated Movie Clip of a VSE Strip of the type 'Clip' (imported via the Movie Clip Editor and then added to the VSE via Add -> Clip... -> <Clipname>).

$\endgroup$
  • $\begingroup$ I presume you mean something other than ...sequence_editor.active_strip.name? $\endgroup$ – Ray Mairlot Dec 11 '15 at 16:30
  • $\begingroup$ Yes, because that just returns the sequence's name, not the clip's one. $\endgroup$ – Paul B. Dec 11 '15 at 16:39
  • $\begingroup$ Not quite sure what you mean by reimporting... $\endgroup$ – Paul B. Dec 12 '15 at 11:31
  • $\begingroup$ I guess he means adding it as a fresh strip into the Sequencer again. $\endgroup$ – Samoth Dec 12 '15 at 17:22
2
$\begingroup$

Actually it doesn't seem possible.

When you open the Add menu (Shift+A) you will see a list of all currently loaded Clips that have been opened in a Movie Clip Editor respectively their current Name properties.

Once you Add a "Clip" to the Sequencer it will initially get the original MovieClips name. But the corresponding MovieClip from the Strip of the Type MovieClipSequence being titled Clip in the Strips properties is only internally referenced. You cannot access it from the Sequencer anymore nor through the Python API. You can proof this via an Outliner view which is set to Datablocks Display Mode. There you can see all your Movie Clips in your Blendfile Data. Those have a name Property which can be set through Python via bpy.data.movieclips["clip_name"].name. Not that the Movie Clip is of the RNA Type MovieClip.

But when you look at your Scenes, <scene_name>, Sequence Editor, Sequence Editor, All sequences you can see all of your added Strips including the added Movie Clip (with it's original name) and an own name property which can be edited via bpy.data.scenes['Scene'].sequence_editor.sequences_all["clip_name"].name. Note its RNA Type MovieClipSequence.

When you now change the name of the MovieClip in the Sequencer you change the name of the MovieClipSequence object which can differ from the name of your MovieClip object. And only when they match the Strip in the sequencer will only show one name followed by a | and the MovieClipSequencer objects frame length. But as soon as you change one of these names, both will be displayed, the MovieClipSequenc objects first, followed by a colon : and the MovieClip objects name (followed by the | and the MovieClipSequence objects frame length). Unselected it's all a bit hard to read as imported Clips get a dark blue strip color by default.

But as soon as you see a colon : in a Clip strips name in the sequencer you can no longer match a MovieClip and a MovieClipSequencer as you cannot get the other ones name from one of these objects in Python as you can see there is no such link neither in the Python autocompletion nor in the Outliners Datablocks display mode. It's all handled internally by Blender for now.

$\endgroup$
  • $\begingroup$ Thank you! That is exactly what I wanted to know (although I find it very sad that it currently is that way). $\endgroup$ – Paul B. Dec 12 '15 at 17:28
  • $\begingroup$ Yeah... - but I'm happy I found something out about the Clips and how they work. Didn't use them yet in my projects. It's great to be able to insert them directly into the VSE using the undistortion feature and other advantages normal Movie Strips don't have. Anyways, feel free to open a Feature Request... $\endgroup$ – Samoth Dec 12 '15 at 17:35
3
$\begingroup$

The active 'clip name' is the only real reference at the moment so avoid 'renaming' in VSE:

import bpy

seq = bpy.data.scenes['Scene'].sequence_editor
strip_name = seq.active_strip.name

print (bpy.data.movieclips[strip_name].filepath)

Console output: /home/user/videos/file_name.mp4


Otherwise (although not ideal) you could iterate through bpy.data.movieclips and compare the duration of the 'active strip' with 'all other' clips:

import bpy

seq = bpy.data.scenes['Scene'].sequence_editor
strip = seq.active_strip
strip_duration = strip.frame_duration

for i in bpy.data.movieclips:
    if (i.frame_duration == strip_duration):
        print (i.filepath)
$\endgroup$
  • $\begingroup$ This goes in the right direction, but when renaming the strip in vse this method - sadly - no longer applies. $\endgroup$ – Paul B. Dec 12 '15 at 15:52
  • $\begingroup$ Jep I know, but it seems that this is your only chance to get the clip directly, since there is no unique id at the moment. $\endgroup$ – p2or Dec 12 '15 at 16:03
  • $\begingroup$ Yeah... There seems to be one (because in vse the strip is named like that: "<name>: <clipname>"). It was sort of my question whether it is accessible it via Python :). $\endgroup$ – Paul B. Dec 12 '15 at 16:06
  • $\begingroup$ @PaulBrachmann As you can see it is accessible, but with limitations (at the moment). I've also tried comparing the clip pointers and thought about other solutions but unfortunately without any real success. Just out of interest: What you are trying to achieve? $\endgroup$ – p2or Dec 13 '15 at 15:21
  • 1
    $\begingroup$ I'm working on an AddOn that "precomposes" vse clips into scenes editeable via the compositor (in order to establish a NUKE like VFX/Compositing workflow in Blender). Therefore I have to know what the corresponding MovieClip to a MovieClipSequence is (to later on import it into the node editor). $\endgroup$ – Paul B. Dec 13 '15 at 15:36
0
$\begingroup$

This Answer was given before OPs edit while the question was still very vague, see my other answer as well.

Just Run this Script in a Text Editor:

import bpy
for seq in bpy.data.scenes['Scene'].sequence_editor.sequences_all:
    print(seq.name)

You should then see the desired output in the System Console (Toggle via Window menu).

When you hover over a Strips name property, you get the Python hint: MovieClipSequence.name and its Python path below: bpy.data.scenes['Scene'].sequence_editor.sequences_all["clip_name"].name.

You can import your MovieClips in an Editor/View of the type MovieClipEditor where there is the MovieClip selection in its menu bar. When you hover over an imported and selected clip in this Dropdown Box you will see the Python hint: MovieClip.name with its the Python path below: bpy.data.movieclips["clip_name"].name - there are more Python properties on the MovieClip directly accessible like its complete filepath, the count of its users, its dimensions as a size-array (with [0] being width and [1] being height) or its source type (movie, image, ...) and more.

$\endgroup$
  • $\begingroup$ "AttributeError: 'MovieClipSequence' pbject has not attribute 'elements'" Besides: Are you sure that is the right way of getting a Movie Clip's name (because if so, wouldn't bpy.context.scene.sequence_editor.active_strip.filename do the job as well)? $\endgroup$ – Paul B. Dec 12 '15 at 11:35
  • $\begingroup$ no, not each strip has a filename. Even a MovieClipSequence doesn't have one... You can just get the name, I edited the answer. $\endgroup$ – Samoth Dec 12 '15 at 14:21
  • $\begingroup$ There is no need to iterate through the sequences since you can use active_strip. To provide a different answer than mine (both looking more and more the same) you could check if the select attribute is true or false. $\endgroup$ – p2or Dec 12 '15 at 14:49
  • $\begingroup$ @poor: Yeah, one can use active_strip, but then the script is dependant on a selection. By iterating it isn't, you will get all the names from all the clips. $\endgroup$ – Samoth Dec 12 '15 at 15:56
  • $\begingroup$ Who was downvoting this answer and why? Please leave a comment if somebody downvotes. $\endgroup$ – Samoth Jan 31 '16 at 22:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.