tagosaku Posted September 14, 2022 Share Posted September 14, 2022 Hi, I am a senior Houdini artist, but a intermediate about python script. I am looking for flipbook tool because original one is so inconvenient that every time we need to type file name and saving path. Thus, I wonder if we have the following tool: 1 click a shelf tool. 2 pop up a custom UI. 3 type rez, frame range, and automatically create a default image file name and its path in the UI, based on hip file. 4 click a button and start playblast and save the image seq. 5 Ideally it has option to save mp4 with ffmpeg. (I have no idea how to plugin this external software!! ) I cannot make such a tool from full scratch, but am capable to customize it. So far, I found useful article, and can read it but don't know, for instance, I can create a custom UI but don't know how to link those values to actual flipbook parameters. I really appreciate if you have python shelf scripts for 5 steps, or more hints to create the tool. Quote Link to comment Share on other sites More sharing options...
DonRomano Posted September 14, 2022 Share Posted September 14, 2022 I can give you hints on how to start this : import roptoolutils, os, hou, subprocess # Getting default start and end frame start_frame, end_frame = hou.playbar.frameRange() # Gathering values input from the user button_idx, values = hou.ui.readMultiInput( "Set the flipbook options", ("Start Frame", "End Frame", "Width", "Height", "Convert To Video"), initial_contents=(str(int(start_frame)), str(int(end_frame)), "1920", "1080", "Yes"), title="Flipbook Options", buttons=("OK", "Cancel"), default_choice=0, close_choice=1, ) # If the user clicks ok if button_idx != 1: new_start_frame = int(values[0]) new_end_frame = int(values[1]) new_width = int(values[2]) new_height = int(values[3]) convert_to_video = True if (values[4] == "Yes") else False # Creating an opengl rop ogl_rop = roptoolutils.createRenderNode("opengl") # optional, if a camera node is selected, set the output camera to be the selected one selected_nodes = hou.selectedNodes() if len(selected_nodes) > 0: n = selected_nodes[0] if n.type().name() == "cam": ogl_rop.parm("camera").set(n.path()) # Setting a bunch of parms ogl_rop.parm("trange").set(1) ogl_rop.parm("f1").set(new_start_frame) ogl_rop.parm("f2").set(new_end_frame) ogl_rop.parm("tres").set(1) ogl_rop.parm("res1").set(new_width) ogl_rop.parm("res2").set(new_height) # Creating the output directory, increments if it already exists version = 1 output_dir = "{}/flipbook/{}".format(hou.getenv("HIP"), "{}".format(version).zfill(3)) while os.path.exists(output_dir): version += 1 output_dir = "{}/flipbook/{}".format(hou.getenv("HIP"), "{}".format(version).zfill(3)) os.makedirs(output_dir) # Setting the output path of the images output_path = "{}/flipbook_img.$F.png".format(output_dir) ogl_rop.parm("picture").set(output_path) # Launch the ogl rop render print("Launching opengl render...") ogl_rop.parm("execute").pressButton() # Conversion to video with ffmpeg, assuming ffmpeg is in the PATH if convert_to_video: print("Converting to video using ffmpeg...") subprocess.check_output(["ffmpeg", "-i", output_path.replace("$F", "%d"), "{}/flipbook_video.mp4".format(output_dir)]) else: print("Flipbook cancelled...") Quote Link to comment Share on other sites More sharing options...
tagosaku Posted September 16, 2022 Author Share Posted September 16, 2022 Thank you so much, Romain. I think this is for openGL rendering in rop, not flipbook, isn't it? I mean this script is still really useful to study the whole logic, but not execute flipbook and save it as jpg sequence ?!? Quote Link to comment Share on other sites More sharing options...
DonRomano Posted September 16, 2022 Share Posted September 16, 2022 Well, I know that there is a menu called MainMenuMPlay.xml where you can append elements (such as python scripts) and execute them in MPlay, that way you could modify what I sent and use a mplay hscript command to save images. I don't have a lot of time today to test, maybe next week ! Cheers, Quote Link to comment Share on other sites More sharing options...
tagosaku Posted September 16, 2022 Author Share Posted September 16, 2022 Because default MPlay sucks, many post productions have own flipbook tools. Anyway, yes, definitely no push to do it for you, and I'll keep searching resources. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.