# How to get the length of an mp4 video inside a node?

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
##print(video.lenght)##


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

• Ty sambler, That's exactly what I was looking for – Pastrokkio Jul 2 at 17:10

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

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