)2h-ddlmZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z mZddlmZmZmZmZmZddlmZmZmZddlmZd Zd ZGd d ZGd deZGddeZeedZ ddddZ!y))UnionN)IO) VideoFromFile)MinimaxVideoGenerationRequestMinimaxVideoGenerationResponseMinimaxFileRetrieveResponseMinimaxTaskResultResponseSubjectReferenceItemModel) ApiEndpoint HttpMethodSynchronousOperationPollingOperation EmptyRequest)download_url_to_bytesioupload_images_to_comfyapivalidate_string) PromptServerrc eZdZdZeZedZdZdZ dZ dZ dZ dZ d d ejd ejd eedffd Zy)MinimaxTextToVideoNodezh Generates videos synchronously based on a prompt, and optional parameters using MiniMax's API. c fdddddfddgddd fd d tjd d d dddfidddddS)NSTRINGT)Text prompt to guide the video generation multilinedefaulttooltipT2V-01zT2V-01-Director!Model to use for video generationrr ) prompt_textmodelseedr,The random seed used for creating the noise.rminmaxcontrol_after_generater AUTH_TOKEN_COMFY_ORGAPI_KEY_COMFY_ORG UNIQUE_ID auth_token comfy_api_key unique_idrequiredoptionalhidden)rINTss DD:\ComfyUI_windows_portable\ComfyUI\comfy_api_nodes\nodes_minimax.py INPUT_TYPESz"MinimaxTextToVideoNode.INPUT_TYPES(s %)#%#N !) $,#F *FF#$ 126#Q   5!4(C& & VIDEOz1Generates videos from prompts using MiniMax's APIgenerate_videoapi node/video/MiniMaxTNimagesubjectr3c | t|dd}|t|d|d}d} |t|d|d} t| g} tt dt j tt tt||d|| d | } | j} | j} | std | jtt d t jt t"d| idgdgd|j$||} | j}|j&}| tdtt dt jt t(dt+|it!| }|j}|j,j.}|td|j1t3j4d||rXt7|j,drd|d|j,j8}nd|}t:j<j?||tA|}|%d|}t3jB|t|tE|fS)zp Function used between MiniMax nodes - supports T2V, I2V, and S2V, based on provided arguments. Nr$) field_name) max_images auth_kwargsr)rBz/proxy/minimax/video_generation)pathmethod request_modelresponse_model)r%prompt callback_urlfirst_frame_imagesubject_referenceprompt_optimizer)endpointrequestrHzMiniMax generation failed: z%/proxy/minimax/query/video_generationtask_id)rIrJrKrL query_paramsSuccessFailc.|jjS)N)statusvalue)xs r;z7MinimaxTextToVideoNode.generate_video..s qxx~~r=) poll_endpointcompleted_statusesfailed_statusesstatus_extractorestimated_durationnode_idrHz,Request was not successful. Missing file ID.z/proxy/minimax/files/retrievefile_idz3No video was found in the response. Full response: zGenerated video URL: backup_download_urlz Result URL: z Backup URL: zFailed to download video from )#rrr rr r POSTrrr executerT Exception base_resprGETrr AVERAGE_DURATIONrcrintfile download_url model_dumplogginginfohasattrrdrinstancesend_progress_textrerrorr)selfr$r&r%rBrCr3kwargs image_urlrP subject_urlvideo_generate_operationresponserT task_resultrcfile_retrieve_operation file_resultfile_urlmessagevideo_io error_msgs r;r@z%MinimaxTextToVideoNode.generate_videoYs = KM B  1%ASYZ[\]I!  3GW]^_`aK!5K!H I $8 6!;=  2El"!"+"3!% $  ",335""9(:L:L9MNO O#3%<!~~*8'1 !*{#H5#44$  /668 %% ?JK K"6 4!~~*:'W6 !N # .557 ##00  EkF\F\F^E_`   ,XJ78 {'')>?( .AQAQAeAe@fg( 3  ! ! 4 4Wi H*84  8 CI MM) $I& &h'))r=)rr!NNN)__name__ __module__ __qualname____doc__T2V_AVERAGE_DURATIONrj classmethodr< RETURN_TYPES DESCRIPTIONFUNCTIONCATEGORYAPI_NODE OUTPUT_NODEtorchTensorrstrr@r=r;rr!s,' ' RLEKH'HHK  "$(e* || e*  e*d#e*r=rc<eZdZdZeZedZdZdZ dZ dZ dZ dZ y) MinimaxImageToVideoNodes Generates videos synchronously based on an image and prompt, and optional parameters using MiniMax's API. c tjddifdddddfgdd d d fd d tjddddddfidddddS)Nr z/Image to use as first frame of video generationrTrrr)zI2V-01-DirectorI2V-01z I2V-01-liverr"r#)rBr$r%r&rr'r(r)r-r.r/r0r4rIMAGEr8r9s r;r<z#MinimaxImageToVideoNode.INPUT_TYPESs HH!#T%)#%#N  $,#F 8FF#$ 126#Q   5!4(Q- - r=r>>Generates videos from an image and prompts using MiniMax's APIr@rATN)rrrrI2V_AVERAGE_DURATIONrjrr<rrrrrrrr=r;rrsB,. . `LRKH'HHKr=rc<eZdZdZeZedZdZdZ dZ dZ dZ dZ y) MinimaxSubjectToVideoNoderc tjddifdddddfdgdd d fd d tjd d ddddfidddddS)Nr z.Image of subject to reference video generationrTrrrzS2V-01r"r#)rCr$r%r&rr'r(r)r-r.r/r0r4rr9s r;r<z%MinimaxSubjectToVideoNode.INPUT_TYPESs HH!#S%)#%#N !$,#F 4FF#$ 126#Q   5!4(M+ + r=r>rr@rATN)rrrrrrjrr<rrrrrrrr=r;rrsB,, , \LRKH'HHKr=r)rrzMiniMax Text to VideozMiniMax Image to VideozMiniMax Subject to Video)rrr)"typingrrorcomfy.comfy_types.node_typingr comfy_api.input_impl.video_typesrcomfy_api_nodes.apisrrrr r r comfy_api_nodes.apis.clientr r rrrcomfy_api_nodes.apinode_utilsrrrserverrrrrrrNODE_CLASS_MAPPINGSNODE_DISPLAY_NAME_MAPPINGSrr=r;rs ,:  ]*]*@=4=@; 6;B5667!;r=