From fee1fd8963c39a620936b29cb817823cb5a7fc3e Mon Sep 17 00:00:00 2001 From: bilt Date: Thu, 31 Jul 2025 19:47:01 +0800 Subject: [PATCH] fix --- comfy_api/input_impl/video_types.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/comfy_api/input_impl/video_types.py b/comfy_api/input_impl/video_types.py index ebcbc8c8e..95ba54a04 100644 --- a/comfy_api/input_impl/video_types.py +++ b/comfy_api/input_impl/video_types.py @@ -258,11 +258,24 @@ class VideoFromComponents(VideoInput): codec: VideoCodec = VideoCodec.AUTO, metadata: Optional[dict] = None ): - if format != VideoContainer.AUTO and format != VideoContainer.MP4: + if format == VideoContainer.AUTO: + format = VideoContainer.MP4 + if codec == VideoCodec.AUTO: + codec = VideoCodec.H264 + + if format != VideoContainer.MP4: raise ValueError("Only MP4 format is supported for now") - if codec != VideoCodec.AUTO and codec != VideoCodec.H264: + if codec != VideoCodec.H264: raise ValueError("Only H264 codec is supported for now") - with av.open(path, mode='w', options={'movflags': 'use_metadata_tags'}) as output: + + open_kwargs = { + 'mode': 'w', + 'options': {'movflags': 'use_metadata_tags'} + } + if isinstance(path, io.BytesIO): + open_kwargs['format'] = format.lower() + + with av.open(path, **open_kwargs) as output: # Add metadata before writing any streams if metadata is not None: for key, value in metadata.items():