Fixing Filename Prefix In ComfyUI Save Video Node
If you're encountering problems with filename prefix formatting in ComfyUI's Save Video node, you're not alone. Many users have faced similar issues where the output files don't adhere to the expected naming conventions. This comprehensive guide will walk you through the common causes and solutions to ensure your video files are named correctly.
Understanding the Issue
The core problem lies in the filename_prefix widget of the Save Video node. Ideally, this feature should allow users to dynamically name their video files using variables from other nodes, such as the KSamplerAdvanced node's noise seed or the LoadImage node's image name. According to the ComfyUI documentation, you should be able to use bracketed expressions like %LoadImage.image%_%KSamplerAdvanced.noise_seed% to achieve this.
However, users have reported that instead of substituting the actual values, the output files are named with the literal text of the expressions, like ComfyUI_%KSamplerAdvanced.noise_seed%_0001. Additionally, using date formatting prefixes such as %date:yyyy-MM-dd% can lead to even more significant issues, sometimes resulting in zero-byte files with incorrect filenames.
Diagnosing the Problem
Before diving into solutions, it's crucial to understand the potential causes. Here are some common reasons why filename prefix formatting might not work as expected:
- Incorrect Syntax: Even a small typo in the filename prefix expression can prevent it from being parsed correctly. Ensure that the node names and variable names within the brackets are accurate and that the syntax matches the documentation.
- Custom Node Conflicts: While ComfyUI is highly extensible, custom nodes can sometimes interfere with the core functionality. It's a good practice to disable custom nodes temporarily to see if they are the cause.
- Software Bugs: Like any software, ComfyUI may have bugs that affect certain features. Check the ComfyUI's GitHub repository for known issues and discussions related to filename formatting.
- Default Node Titles and S&R Names: The reported issue mentions that using default node titles and S&R names might be a factor. This suggests that the system might not be correctly identifying the nodes when their default names are unchanged.
Step-by-Step Solutions
Now that we understand the potential causes, let's explore the solutions. Follow these steps to troubleshoot and fix your filename prefix formatting issues:
1. Verify the Syntax
The first step is to double-check the syntax of your filename_prefix expression. Ensure that:
- Node names are spelled correctly and match the actual node titles in your workflow.
- Variable names are accurate and correspond to the available outputs of the respective nodes.
- The brackets and percentage signs are correctly placed.
- Date formatting strings (if used) are valid and follow the expected format.
For example, if you want to include the image name from a Load Image node and the noise seed from a KSamplerAdvanced node, your expression should look like this:
%LoadImage.image%_%KSamplerAdvanced.noise_seed%
2. Test with Simplified Expressions
To isolate the issue, try using a simplified filename_prefix expression. For instance, use only one variable, such as the image name from the Load Image node:
%LoadImage.image%
If this works, it indicates that the problem might be related to combining multiple variables or a specific node. If it doesn't work, the issue is likely with the basic syntax or the Load Image node itself.
3. Rename Nodes and S&R Names
As mentioned earlier, the issue might be related to using default node titles and S&R names. To address this, try renaming the relevant nodes in your workflow. For example, rename the Load Image node to something unique like MyLoadImage and the KSamplerAdvanced node to MyKSampler. Then, update your filename_prefix expression accordingly:
%MyLoadImage.image%_%MyKSampler.noise_seed%
By renaming the nodes, you ensure that the system can correctly identify them when parsing the filename prefix.
4. Disable Custom Nodes
Custom nodes can sometimes introduce conflicts or bugs. To rule out this possibility, disable all custom nodes and test the filename_prefix formatting again. If the issue is resolved, re-enable the custom nodes one by one to identify the culprit.
To disable custom nodes, you can typically find an option in ComfyUI's settings or use a command-line argument when launching the application. Refer to the ComfyUI documentation for specific instructions.
5. Check for Known Issues and Bug Reports
Before spending too much time troubleshooting, check the ComfyUI's GitHub repository for known issues and bug reports related to filename formatting. Other users may have encountered the same problem and found a solution or workaround. You can also contribute to the discussion and provide details about your specific situation.
6. Update ComfyUI
Ensure you are using the latest version of ComfyUI. Software updates often include bug fixes and improvements that can resolve issues like this. Check the official ComfyUI channels for update instructions.
7. Review Debug Logs
Debug logs can provide valuable insights into what's happening behind the scenes. Examine the logs for any error messages or warnings related to filename formatting. The provided debug logs in the original issue show the prompt execution times and loaded models, but they don't directly indicate a filename formatting error. However, if you encounter errors related to file saving or node execution, they might be related to the problem.
8. Test Date Formatting Separately
If you're using date formatting in your filename_prefix, test it separately to see if it's the source of the issue. Try using only the date format string and no other variables:
%date:yyyy-MM-dd%
If this causes problems, the issue is likely with the date formatting implementation. Check the ComfyUI documentation and community discussions for known issues and workarounds.
9. Examine the Workflow
Sometimes, the issue might be related to the overall workflow configuration. Ensure that all nodes are correctly connected and that there are no conflicting settings. In the provided workflow file (WAN 2.2 I2V Workflow With Low VRAM.json), review the connections and settings of the Save Video node and the nodes it depends on.
Example Scenario and Solution
Let's consider a scenario where you want to name your video files using the image name from a Load Image node and the seed from a KSampler node. You've entered the following filename_prefix:
%LoadImage.image%_%KSampler.seed%
However, the output files are named like ComfyUI_%LoadImage.image%_%KSampler.seed%_0001. Here's how you can troubleshoot and fix the issue:
-
Verify Syntax: Double-check the spelling of the node names and variable names. Ensure that
LoadImageandKSamplerare the correct node titles and thatimageandseedare the correct output variables. -
Rename Nodes: Rename the Load Image node to
MyImageLoaderand the KSampler node toMySampler. Update the filename_prefix to:%MyImageLoader.image%_%MySampler.seed% -
Test: Run the workflow again. If the files are now named correctly, the issue was likely related to the default node names.
Conclusion
Filename prefix formatting issues in ComfyUI's Save Video node can be frustrating, but with a systematic approach, you can identify and resolve the problem. By verifying syntax, testing simplified expressions, renaming nodes, disabling custom nodes, and checking for known issues, you can ensure that your video files are named correctly and efficiently manage your creative workflow.
For more information and community support, visit the official ComfyUI GitHub repository. You'll find discussions, bug reports, and valuable insights from other users and developers.