在Blender中,我如何在视频编辑器(VSE)中获取图像序列的源文件名?

huangapple go评论93阅读模式
英文:

In Blender how I can get an ImageSequence source filename in video editor (VSE)?

问题

在Blender中,当您使用视频编辑器(VSE)时,可以像这样使用Python解析项目:

import bpy
import os

for seq in bpy.context.sequences:
  sFull_filename = ""
  if seq.type == "MOVIE":
    sFull_filename = seq.filepath
  if seq.type == "SOUND":
    sFull_filename = seq.sound.filepath
  if seq.type == "IMAGE":
    sFull_filename = "??"
    sName = seq.name       # /!\ It is not the file name !
    sPath = seq.directory
  # Finally
  sAbsolute_name = bpy.path.abspath( sFull_filename )

正如您所看到的,我可以获取电影和声音的文件名,但如何获取图像的文件名呢?

在Blender API文档网站上,我找不到如何执行此操作的说明...

我尝试获取VSE图像条带的文件名...

英文:

In Blender, when you use Video Editor (VSE), you can parse items using Python like this :

import bpy
import os

for seq in bpy.context.sequences:
  sFull_filename = ""
  if seq.type == "MOVIE":
    sFull_filename = seq.filepath
  if seq.type == "SOUND":
    sFull_filename = seq.sound.filepath
  if seq.type == "IMAGE":
    sFull_filename = "??"  # How to get it for images ?
    sName = seq.name       # /!\ It is not the file name !
    sPath = seq.directory
  # Finally
  sAbsolute_name = bpy.path.abspath( sFull_filename )

As you can see, I get the filename for movies and sound, but how can I get it for images ?

On Blender api documentation website I don't found how to do it...

I try to get VSE images strip file names...

答案1

得分: 1

你可以从seqelements列表中获取名称:

    ...
    elif seq.type == "IMAGE":
        # 获取第一个图像文件名
        sFull_filename = os.path.join(seq.directory, seq.elements[0].filename)  

    sAbsolute_name = bpy.path.abspath(sFull_filename)
    print(sAbsolute_name)

或者如果你想获取它们所有,可以迭代seq.elements

英文:

You can get the names from elements list of seq:

    ...
    elif seq.type == "IMAGE":
        # Get the first image filename
        sFull_filename = os.path.join(seq.directory, seq.elements[0].filename)  

    sAbsolute_name = bpy.path.abspath(sFull_filename)
    print(sAbsolute_name)

or if you want them all, iterate over seq.elements

huangapple
  • 本文由 发表于 2023年4月13日 21:20:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005943.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定