Nodes/ComfyUI-KYNode/KY_FFmpeg: Custom Command (Advanced)
ComfyUI Node

KY_FFmpeg: Custom Command (Advanced)

The escape hatch for everything the other nodes don't cover

By yorkane·Created 2 years ago·Updated 6 months ago· 10
KY_FFmpeg: Custom Command (Advanced)
    • output_video_path
    command_template-i {input_1} -c:v {param_1} -crf 23 {output_file}
    input_1C:/path/to/input.mp4
    output_fileC:/path/to/custom_output.mp4
    input_2
    param_1libx264
    param_2
    param_3
    hw_accel_pre_flags

    The other KY_FFmpeg* nodes cover specific jobs - merge audio, extract frames, trim by duration. This one covers everything else: you write your own ffmpeg command as a template, and the node fills in your actual file paths and parameters before running it. It's the node for when your task doesn't match any of the pack's dedicated wrappers.

    How the templating works

    command_template is a string with placeholder tokens: {input_1}, {input_2}, {output_file}, {param_1}, {param_2}, {param_3}. The default template shows the pattern: -i {input_1} -c:v {param_1} -crf 23 {output_file} - a plain re-encode with a chosen codec at CRF 23. You write whatever ffmpeg flags you need around those tokens, and the node substitutes in your actual values before shelling out to ffmpeg.

    param_1 gets its own enum of common video codecs: libx264, h264_nvenc, libx265, hevc_nvenc, prores_ks, libvpx-vp9 - covering software and NVENC-accelerated H.264/H.265, ProRes, and VP9. param_2/param_3 are freeform strings with no built-in meaning - what they represent is entirely up to how you reference them in your own command_template. hw_accel_pre_flags gives you a preset for GPU decode acceleration (-hwaccel cuda, -hwaccel cuda -vsync passthrough, -hwaccel vulkan, -hwaccel dxva2), inserted ahead of the input per how ffmpeg expects hardware-acceleration flags to be placed.

    Inputs and output

    Required: command_template, input_1, output_file. Optional: input_2, param_1, param_2, param_3, hw_accel_pre_flags. One output: output_video_path.

    Installing it

    ComfyUI Manager: search ComfyUI-KYNode, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yorkane/ComfyUI-KYNode
    

    Restart ComfyUI. Needs ffmpeg installed and on PATH, same as the rest of the family - this node has no built-in fallback since its entire job is running whatever ffmpeg command you give it.

    Common issues

    This node offers zero validation of your command - a typo in the template, a flag combination that doesn't parse, or a codec that isn't actually available in your ffmpeg build will fail exactly the way it would if you ran the same command in a terminal. If something goes wrong, the fastest debugging step is copying your substituted command and running it directly in a shell to see the real ffmpeg error.

    Codec choice has to match your actual hardware and ffmpeg build: picking h264_nvenc or hevc_nvenc without an NVIDIA GPU (or without an ffmpeg build compiled with NVENC support) will error out, and the same goes for the -hwaccel cuda flags in hw_accel_pre_flags.

    param_2 and param_3 carry no documented meaning of their own - they're just string slots you can reference however your command_template uses them, so if you're reusing someone else's template, make sure you understand what each placeholder is actually supposed to be before filling them in.

    And since this node writes real files via a real external process, treat it with the same caution you'd give any command-line tool - an incorrect output_file path pointing somewhere you didn't intend will overwrite whatever's already there.

    CategoryVideo/KY_FFmpeg/Advanced

    Inputs (8)

    NameTypeDefaultDescription
    command_templateSTRING-i {input_1} -c:v {param_1} -crf 23 {output_file}
    input_1STRINGC:/path/to/input.mp4
    output_fileSTRINGC:/path/to/custom_output.mp4
    input_2optSTRING
    param_1optCOMBOlibx2646 options: libx264, h264_nvenc, libx265, hevc_nvenc, prores_ks, libvpx-vp9
    param_2optSTRING
    param_3optSTRING
    hw_accel_pre_flagsoptCOMBO5 options: , -hwaccel cuda -vsync passthrough, -hwaccel cuda, -hwaccel vulkan, -hwaccel dxva2

    Outputs (1)

    NameTypeDescription
    output_video_pathSTRING