Jump to content

Handling image sequences


Recommended Posts

Hi,

I'm creating a wall of TVs and each TV will have a different image displayed on. So I want to change the image sequence being shown based upon a random value.

My problem is that each sequence is a different number of files, and I need the video to loop. I can do something like this

$HIP/images/video`ch('video')`/image_`padzero(3,wrap($F,1,500))`.png

Where 500 is the length of the video sequence.

Is there an hscript expression that will tell me how long the sequence is?

Link to comment
Share on other sites

if you read your sequence into File COP and then using expression like:

seqlength()

or in Python

sequenceFrameLength()

will tell you that

so to be more effective, create little python script that will loop all your sequences, get their lengths by loading them to a single File COP one by one and outputs lengths to file or to some node as custom data or somewhere

or if you do it in Python SOP, then you can store that data directly to corresponding points of your TV grid

Just make sure it's not realtime, but as a callback script for some button

Edited by anim
Link to comment
Share on other sites

Haven't testing it, just a quick sketch, but something like this should work in text filed

import os
HIP = hou.expandString("$HIP")
videoFolder = "video_%d" % 1 # random number here
pathToSeq = "%s/images/%s" % (HIP,videoFolder) # fullPath to video folder
seqLength = len(os.listdir(pathToSeq)) 
F = int(hou.hmath.wrap(hou.frame(),1,seqLength)) #frame wraping
F = str(F).zfill(4) #padding
fileName = "image_%s.png" % F
fullPath = "%s/%s" % (pathToSeq,fileName)
return fullPath

  • Thanks 1
Link to comment
Share on other sites

Haven't testing it, just a quick sketch, but something like this should work in text filed

import os
HIP = hou.expandString("$HIP")
videoFolder = "video_%d" % 1 # random number here
pathToSeq = "%s/images/%s" % (HIP,videoFolder) # fullPath to video folder
seqLength = len(os.listdir(pathToSeq)) 
F = int(hou.hmath.wrap(hou.frame(),1,seqLength)) #frame wraping
F = str(F).zfill(4) #padding
fileName = "image_%s.png" % F
fullPath = "%s/%s" % (pathToSeq,fileName)
return fullPath

To clean things up a bit, that could be put into the session module as a function. Then call the function with hou.session.defNameHere(argsHere). The session module gets saved into the scene file.

http://www.sidefx.com/docs/houdini11.0/hom/session

If a Python expression is going to take more than a single line then I will put it into the session module (or an external module) to keep things as organized as possible. If you find you need it later in a another scene then the session can be exported as a stand alone Python script and then imported into another scene.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...