Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

hopbin9

Handling image sequences

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?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now