Work with python in blender 2.8 , i try to find a command for get the lenght of an video inside at image node.

ob = bpy.context.active_object
nodes = ob.active_material.node_tree.nodes

    for n in nodes:
        if n.name == "Image Texture":
            if n.image:
                video = n.image

The length of a video file is stored in the frame_duration property.

num_frames = n.image.frame_duration

If you wanted duration in time, divide the frames by the fps property.

seconds = num_frames / n.image.fps
  • $\begingroup$ Ty sambler, That's exactly what I was looking for $\endgroup$ – Pastrokkio Jul 2 at 17:10

I think your script need to check if fn.lower().endswith('.mp4')

  • $\begingroup$ Ty Alexa, i have if statement now $\endgroup$ – Pastrokkio Jul 2 at 17:11

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.