Comfy-Org / Comfy-Org/ComfyUI

[Bug]: av.error.ArgumentError in video_types.py when muxing audio on macOS (AAC encoder rejects container movflags)

Open
#14,755 0 comments 0 reactions 0 assignees View on GitHub
Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

The video and audio tracks should mux together and save successfully. Container-level metadata flags (like movflags) should be isolated to the container configuration and not passed directly into individual audio stream codec initializations.

### Actual Behavior

When attempting to save a video combined with an audio track using the native ComfyUI video saving API on macOS, the execution crashes with a fatal ArgumentError.

The underlying av.open() call passes container-level flags (options={'movflags': 'use_metadata_tags'}) globally. This leaks down to individual stream codecs. The native avcodec_open2 handler for the "aac" audio stream does not recognize this option, returning error code 22 (Invalid Argument) and killing the execution loop.

### Steps to Reproduce

Run ComfyUI on macOS (Apple Silicon using the mps backend) with Python 3.12.

Build a workflow that outputs or loads a video file and binds it together with an audio stream (like an RVC or TTS track).

Connect the outputs to a native video saving/preview node that uses comfy_extras/nodes_video.py.

Queue the prompt and watch the terminal throw an error right at the final step during audio muxing.

### Debug Logs

```powershell
File "/Users/kcla/Dev/ComfyUI/comfy_extras/nodes_video.py", line 115, in execute
video.save_to(
File "/Users/kcla/Dev/ComfyUI/comfy_api/latest/_input_impl/video_types.py", line 570, in save_to
output.mux(packet)
File "av/container/output.py", line 457, in av.container.output.OutputContainer.start_encoding
ctx.open()
File "av/codec/context.py", line 247, in av.codec.context.CodecContext.open
err_check(
av.error.ArgumentError: Invalid argument: 'avcodec_open2("aac", {\'movflags\': \'use_metadata_tags\'})' returned 22
```

### Other

Box 4: Environment & Additional Context (The technical logs)
System Specs:

OS: macOS (Apple Silicon)

Device backend: mps / cpu

Python version: 3.12

Contributor guide

Open the contributing guide

Research direction

Start with comfy_api/latest/_input_impl/video_types.py around save_to and then trace its caller in comfy_extras/nodes_video.py. Reproduce the audio-and-video workflow on macOS and inspect how container options reach stream codec initialization. Done means the AAC mux completes without ArgumentError while video saving continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.