Kosinkadink / ComfyUI-VideoHelperSuite

Nodes related to video workflows
GNU General Public License v3.0
414 stars 74 forks source link

how to convert the filenames output of the video combine to string ? #202

Open proteus2000 opened 2 months ago

proteus2000 commented 2 months ago

Hi

this is not really an issue. more like a question/ request.

i would like to get the output of the video combine node called filenames as a string. it seems it is a "tuple". do you have an idea how to convert the png and the mp4 filenames to a strings with existing nodes. Or would it be possible to add extra string outputs containing the filenames to the node? would be helpful to directly open files from disk by copy/paste in explorer. and useful to use text in a more complex workflow. Thank you, Boris

proteus2000 commented 2 months ago

Screenshot

image

AustinMroz commented 2 months ago

A tuple is just an immutable list. There's probably a node out there capable of indexing lists, but here's a quick and dirty standalone node you can put in custom_nodes/vhs_filenames.py which will do the trick.

class SELECT_VHS_FILENAME:
    @classmethod
    def INPUT_TYPES(s):
        return {"required": {"filenames": ("VHS_FILENAMES",), "index": ("INT", {"default": -1, "step": 1, "min": -1})}}
    RETURN_TYPES = ("STRING",)
    RETURN_NAMES =("Filename",)
    CATEGORY = "Video Helper Suite 🎥🅥🅗🅢"
    FUNCTION = "select_filename"

    def select_filename(self, filenames, index):
        return (filenames[1][index],)

NODE_CLASS_MAPPINGS = {
    "SELECT_VHS_FILENAME": SELECT_VHS_FILENAME,
}
proteus2000 commented 2 months ago

wow thanks alot. will try that out

moon47usaco commented 1 week ago

This works great, thank you @AustinMroz @Kosinkadink Can you add an official node that does this... =]