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

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

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

问题

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

  1. import bpy
  2. import os
  3. for seq in bpy.context.sequences:
  4. sFull_filename = ""
  5. if seq.type == "MOVIE":
  6. sFull_filename = seq.filepath
  7. if seq.type == "SOUND":
  8. sFull_filename = seq.sound.filepath
  9. if seq.type == "IMAGE":
  10. sFull_filename = "??"
  11. sName = seq.name # /!\ It is not the file name !
  12. sPath = seq.directory
  13. # Finally
  14. 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 :

  1. import bpy
  2. import os
  3. for seq in bpy.context.sequences:
  4. sFull_filename = ""
  5. if seq.type == "MOVIE":
  6. sFull_filename = seq.filepath
  7. if seq.type == "SOUND":
  8. sFull_filename = seq.sound.filepath
  9. if seq.type == "IMAGE":
  10. sFull_filename = "??" # How to get it for images ?
  11. sName = seq.name # /!\ It is not the file name !
  12. sPath = seq.directory
  13. # Finally
  14. 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列表中获取名称:

  1. ...
  2. elif seq.type == "IMAGE":
  3. # 获取第一个图像文件名
  4. sFull_filename = os.path.join(seq.directory, seq.elements[0].filename)
  5. sAbsolute_name = bpy.path.abspath(sFull_filename)
  6. print(sAbsolute_name)

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

英文:

You can get the names from elements list of seq:

  1. ...
  2. elif seq.type == "IMAGE":
  3. # Get the first image filename
  4. sFull_filename = os.path.join(seq.directory, seq.elements[0].filename)
  5. sAbsolute_name = bpy.path.abspath(sFull_filename)
  6. 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:

确定