Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Houdini flipbook audio #192

Open
1 task done
kahwatikid opened this issue Dec 9, 2024 · 2 comments
Open
1 task done

Houdini flipbook audio #192

kahwatikid opened this issue Dec 9, 2024 · 2 comments

Comments

@kahwatikid
Copy link

Is there an existing issue for this?

  • I have searched the existing issues and added correct labels.

Please describe the feature you have in mind and explain what the current shortcomings are?

Hi Hi!

As per @BigRoy 's request,

It would be great to be able to include audio with flipbook publishes in Houdini. As of 0.4.0 this doesn't seem possible.

This is currently possible when creating a flipbook in houdini if you have audio enabled through the audio panel. It will play the flipbook in MPlay with the timeline audio.

Image

Suggested implementation?

I'm not sure if it would work with CHOPS as it sounds like it would have to be done in post,

  • using the audio file path and offset (check both audio panel and Render Flipbook settings to ensure they are the same.
  • Render the flipbook via ogl rop (as it already does)
  • " encode them to videos with ffmpeg" - BigRoy

Describe alternatives you've considered:

No response

@BigRoy
Copy link
Contributor

BigRoy commented Dec 15, 2024

The audio in Houdini can be managed in Python using the hou.audio module. Oddly enough it seems to only have functions to set the audio track and audio settings - but none seem related to getting the currently set audio track (or I'm blind right now?)

The hou.FlipbookSettings does have a way to query its audio filename, hou.FlipbookSettings.audioFilename(). It also has a method to hou.FlipbookSettings.fromAudioPanel so maybe through that we can get it from the audio panel.

I wonder why it's this hard to find anything about Houdini's audio settings from Python. :)

@BigRoy
Copy link
Contributor

BigRoy commented Dec 16, 2024

Here's an example to query the currently set values - apparently the hscript audiopanel command can print the currently set values.

import hou


def get_audio_settings() -> dict:
    """Return current audio settings.
    
    Uses the hscript `audiopanel` command to
    query the currently configured settings
    and convert them into a dictionary.
    
    """

    settings, _ = hou.hscript("audiopanel")
    mapping = {
        "-s r": "scrubRepeat",
        "-s s": "scrubSustain",
        "-s f": "scrubRate",
        "-s p": "chop",
        "-t p": "testPlayDirection",
        "-t l": "testPlayLoop",
        "-t r": "testPlayRewind",
        "-o m": "mono",
        "-o t": "volumeTied",
        "-o u": "volumeMeter",
        "-o l": "volumeLeft",
        "-o r": "volumeRight",
        # 0 off, 1 timeline, 2 timeslice, 3 test
        "-o d": "audioMode",
        "-r d": "audioOutputDelay",
        # 0 for CHOPs, 1 for Audio Files
        "-m": "source",
        "-a": "file",
        "-f": "audioFrame",
        "-O": "audioOffset"
    }
    
    def _convert_value(value):     
        # Convert to int or float or strip quote of string
        if value.isdigit():
            return int(value)
        else:
            try:
                return float(value)
            except ValueError:
                # strip quotes around filename
                return arg_value.strip("'")
    
    result = {}
    for line in settings.split("\n"):
        line = line.strip()
        if not line:
            continue
            
        args = line[len("audiopanel "):]
        for key, value in mapping.items():
            if args.startswith(key):
                # strip off the argument and the space
                arg_value = args[len(key) + 1:]
                arg_value = _convert_value(arg_value)
                result[value] = arg_value
                break
        else:
            print(f"Unsupported argument line: {line}")
    return result
        

# Example
settings = get_audio_settings()
if settings["source"] == 0:
    # Using chops
    print("Using CHOPs: ", settings["chop"])
elif settings["source"] == 1:
    # Using file
    print("Using file: ", settings["file"])
    
# Let's print the returned values
import json
print(json.dumps(settings, indent=4))

Example output then is:

{
    "chop": "",
    "scrubRepeat": "off",
    "scrubSustain": 24,
    "scrubRate": 24,
    "testPlayDirection": "stop",
    "testPlayLoop": "off",
    "testPlayRewind": "on",
    "mono": "off",
    "volumeTied": "on",
    "volumeMeter": "on",
    "volumeLeft": 1,
    "volumeRight": 1,
    "audioMode": 2,
    "audioOutputDelay": 0.171,
    "source": 1,
    "file": "C:/projects/ayontest/asset/char_beast/work/lighting/sample3.aiff",
    "audioFrame": 1001,
    "audioOffset": 0
}

I asked about whether there are alternative solutions to this on SideFX forum here: https://www.sidefx.com/forum/topic/99147/?page=1#post-434788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants