
    3j              	       V   S r SSKJr  SSKJr  SSKJrJrJrJ	r	  SSK
JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,  SSK-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:  Sr;Sr<S	r=S
r>Sr?Sr@SrA " S S\B\5      rC " S S\B\5      rDS\S\BS-  4S jrES\S\BS-  4S jrF S0S\G\R                     S\BS\IS-  S\4S jjrJ S0S\G\R                     S\S\IS-  S\	R                  4S jjrL " S S\R                  5      rM " S S \R                  5      rN " S! S"\R                  5      rO " S# S$\R                  5      rPS%rQS&rR " S' S(\R                  5      rS " S) S*\R                  5      rT " S+ S,\R                  5      rU " S- S.\5      rVS\V4S/ jrWg)1a  Runway API Nodes

API Docs:
  - https://docs.dev.runwayml.com/api/#tag/Task-management/paths/~1v1~1tasks~1%7Bid%7D/delete

User Guides:
  - https://help.runwayml.com/hc/en-us/sections/30265301423635-Gen-3-Alpha
  - https://help.runwayml.com/hc/en-us/articles/37327109429011-Creating-with-Gen-4-Video
  - https://help.runwayml.com/hc/en-us/articles/33927968552339-Creating-with-Act-One-on-Gen-3-Alpha-and-Turbo
  - https://help.runwayml.com/hc/en-us/articles/34170748696595-Creating-with-Keyframes-on-Gen-3

    )Enum)override)IOComfyExtensionInput	InputImpl)RunwayImageToVideoRequestRunwayImageToVideoResponseRunwayTaskStatusResponseRunwayModelEnumRunwayDurationEnumRunwayAspectRatioEnumRunwayPromptImageObjectRunwayPromptImageDetailedObjectRunwayTextToImageRequestRunwayTextToImageResponseModel4ReferenceImage RunwayTextToImageAspectRatioEnumRunwayAleph2IORunwayAleph2KeyframeChainRunwayAleph2KeyframeItemRunwayAleph2PromptImageChainRunwayAleph2PromptImageItemRunwayAleph2RequestRunwayAleph2ResponseRunwayAleph2KeyframeSecondsRunwayAleph2KeyframeAtRunwayAleph2PromptImageRunwayAleph2TimestampPositionRunwayAleph2RelativePositionRunwayAleph2ContentModerationKEYFRAME_MODE_SECONDSKEYFRAME_MODE_ATPROMPT_IMAGE_MODE_TIMESTAMPPROMPT_IMAGE_MODE_POSITION)image_tensor_pair_to_batchvalidate_stringvalidate_image_dimensionsvalidate_image_aspect_ratiovalidate_video_durationupload_images_to_comfyapiupload_image_to_comfyapiupload_video_to_comfyapidownload_url_to_video_outputdownload_url_to_image_tensorApiEndpointsync_oppoll_opz/proxy/runway/image_to_videoz/proxy/runway/video_to_videoz/proxy/runway/text_to_imagez/proxy/runway/tasks@      )   c                   0    \ rS rSrSrSrSrSrSrSr	Sr
S	rg
)RunwayGen4TurboAspectRatioM   zKAspect ratios supported for Image to Video API when using gen4_turbo model.z1280:720z720:1280z1104:832z832:1104z960:960z1584:672 N)__name__
__module____qualname____firstlineno____doc__field_1280_720field_720_1280field_1104_832field_832_1104field_960_960field_1584_672__static_attributes__r:       </home/wildlama/comfy/ComfyUI/comfy_api_nodes/nodes_runway.pyr8   r8   M   s#    UNNNNMNrG   r8   c                        \ rS rSrSrSrSrSrg)RunwayGen3aAspectRatioX   zLAspect ratios supported for Image to Video API when using gen3a_turbo model.z768:1280z1280:768r:   N)r;   r<   r=   r>   r?   field_768_1280field_1280_768rF   r:   rG   rH   rJ   rJ   X   s    VNNrG   rJ   responsereturnNc                 v    [        U S5      (       a(  [        U R                  5      S:  a  U R                  S   $ g)zAReturns the video URL from the task status response if it exists.outputr   NhasattrlenrQ   rN   s    rH   get_video_url_from_task_statusrV   _   1    x""s8??';a'?q!!rG   c                 v    [        U S5      (       a(  [        U R                  5      S:  a  U R                  S   $ g)zAReturns the image URL from the task status response if it exists.rQ   r   NrR   rU   s    rH   get_image_url_from_task_statusrY   f   rW   rG   clstask_idestimated_durationc           	      f   #    [        U [        [         SU 3S9[        S US S9I S h  vN $  N7f)N/)pathc                     U R                   $ N)statusrs    rH   <lambda>get_response.<locals>.<lambda>t   s    188rG   c                 >    U R                   b  U R                   S-  $ S $ )Nd   )progressrc   s    rH   re   rf   v   s    9OQZZ#%5%YUY%YrG   )response_modelstatus_extractorr\   progress_extractor)r3   r1   PATH_GET_TASK_STATUSTaskStatusResponse)rZ   r[   r\   s      rH   get_responsero   m   sB      017)<=)+-Y   s   (1/1requestc                   #    [        U [        [        SS9[        US9I S h  vN n[	        XR
                  U5      I S h  vN nUR                  (       d  [        S5      e[        U5      n[        U5      I S h  vN $  N\ N@ N7f)NPOSTr_   methodendpointrj   data:Runway task succeeded but no video data found in response.)
r2   r1   PATH_IMAGE_TO_VIDEOr
   ro   idrQ   
ValueErrorrV   r/   )rZ   rp   r\   initial_responsefinal_response	video_urls         rH   generate_videor   z   s     
 %"5fE1	  (-@-@BTUUN  UVV.~>I-i888 V
 9s3    BA?B B9B:B;BBBc                   x    \ rS rSr\S 5       r\S\S\R                  S\S\S\	S\
R                  4S	 j5       rS
rg)RunwayImageToVideoNodeGen3a   c                    [         R                  " SSSS[         R                  R                  SSSSS	9[         R                  R                  S
SS9[         R
                  R                  S[        S9[         R
                  R                  S[        S9[         R                  R                  SSSSSS[         R                  R                  SS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                   /S[         R"                  " [         R$                  " S/S9SS9S9	$ )Nr   z#Runway Image to Video (Gen3a Turbo)partner/video/Runwaya-  Generate a video from a single starting frame using Gen3a Turbo model. Before diving in, review these best practices to ensure that your input selections will set your generation up for success: https://help.runwayml.com/hc/en-us/articles/33927968552339-Creating-with-Act-One-on-Gen-3-Alpha-and-Turbo.promptT Text prompt for the generation	multilinedefaulttooltipstart_frame$Start frame to be used for the videor   durationoptionsratioseedr          Random seed for generationr   minmaxstepcontrol_after_generatedisplay_moder   widgets/{"type":"usd","usd": 0.0715 * widgets.duration}
depends_onexpr	node_iddisplay_namecategorydescriptioninputsoutputshiddenis_api_nodeprice_badger   SchemaStringr   ImageComboDurationrJ   IntNumberDisplaynumberVideoOutputHiddenauth_token_comfy_orgapi_key_comfy_org	unique_id
PriceBadgePriceBadgeDependsrZ   s    rH   define_schema)RunwayImageToVideoNodeGen3a.define_schema   sD   yy1>+y
 		"<	    !B   $   2   "+/!#!1!1!8!88  	'> ! 		..		++		##
 //EJ_3
 3	
rG   r   r   r   r   r   rO   c                 T  #    [        USS9  [        USSS9  [        USS5        [        U USSS9I S h  vN n[        R
                  " [        U [        UU[        S	5      [        U5      [        U5      [        [        [        US
   5      SS9/S9S95      I S h  vN 5      $  No N
7f)Nr   
min_length?  	max_width
max_heightr      r   r   	image/png
max_images	mime_typegen3a_turbor   firsturipositionroot
promptTextr   modelr   r   promptImage)r(   r)   r*   r,   r   
NodeOutputr   r	   Modelr   AspectRatior   r   strrZ   r   r   r   r   r   download_urlss          rH   execute#RunwayImageToVideoNodeGen3a.execute   s      	1-!+$O#K@7!	
 
 }} )%.%h/%e, 7=#mTUFVBWbijk!	 
 	

s"   2B(B$A&B(B&	B(&B(r:   Nr;   r<   r=   r>   classmethodr   r   r   r   intr   r   r   rF   r:   rG   rH   r   r      sk    4
 4
l !
!
 [[!
 	!

 !
 !
 
!
 !
rG   r   c                   x    \ rS rSr\S 5       r\S\S\R                  S\S\S\	S\
R                  4S	 j5       rS
rg)RunwayImageToVideoNodeGen4   c                    [         R                  " SSSS[         R                  R                  SSSSS	9[         R                  R                  S
SS9[         R
                  R                  S[        S9[         R
                  R                  S[        S9[         R                  R                  SSSSSS[         R                  R                  SS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                   /S[         R"                  " [         R$                  " S/S9SS9S9	$ )Nr   z"Runway Image to Video (Gen4 Turbo)r   a  Generate a video from a single starting frame using Gen4 Turbo model. Before diving in, review these best practices to ensure that your input selections will set your generation up for success: https://help.runwayml.com/hc/en-us/articles/37327109429011-Creating-with-Gen-4-Video.r   Tr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r8   r   r   r   r   r   r   r   r   r   r   r   r   s    rH   r   (RunwayImageToVideoNodeGen4.define_schema   sD   yy0=+d
 		"<	    !B   $   6   "+/!#!1!1!8!88  	'> ! 		..		++		##
 //EJ_3
 3	
rG   r   r   r   r   r   rO   c                 Z  #    [        USS9  [        USSS9  [        USS5        [        U USSS9I S h  vN n[        R
                  " [        U [        UU[        S	5      [        U5      [        U5      [        [        [        US
   5      SS9/S9S9[        S9I S h  vN 5      $  Nr N
7f)Nr   r   r   r   r   r   r   r   
gen4_turbor   r   r   r   r   r\   )r(   r)   r*   r,   r   r   r   r	   r   r   r   r   r   r   AVERAGE_DURATION_FLF_SECONDSr   s          rH   r   "RunwayImageToVideoNodeGen4.execute%  s      	1-!+$O#K@7!	
 
 }} )%-%h/%e, 7=#mTUFVBWbijk!	 $@ 
 	

s"   2B+B'A)B+B)	B+)B+r:   Nr   r:   rG   rH   r   r      sk    4
 4
l "
"
 [["
 	"

 "
 "
 
"
 "
rG   r   c                       \ rS rSr\S 5       r\S\S\R                  S\R                  S\S\S\	S	\
R                  4S
 j5       rSrg)RunwayFirstLastFrameNodeiK  c                    [         R                  " SSSS[         R                  R                  SSSSS	9[         R                  R                  S
SS9[         R                  R                  SSS9[         R
                  R                  S[        S9[         R
                  R                  S[        S9[         R                  R                  SSSSSS[         R                  R                  SS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                   /S[         R"                  " [         R$                  " S/S9SS9S9	$ )Nr   z Runway First-Last-Frame to Videor   a  Upload first and last keyframes, draft a prompt, and generate a video. More complex transitions, such as cases where the Last frame is completely different from the First frame, may benefit from the longer 10s duration. This would give the generation more time to smoothly transition between the two inputs. Before diving in, review these best practices to ensure that your input selections will set your generation up for success: https://help.runwayml.com/hc/en-us/articles/34170748696595-Creating-with-Keyframes-on-Gen-3.r   Tr   r   r   r   r   r   	end_framezCEnd frame to be used for the video. Supported for gen3a_turbo only.r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s    rH   r   &RunwayFirstLastFrameNode.define_schemaM  sb   yy.;+k 		"<	    !B   a   $   2   "+/!#!1!1!8!88  	/!F ! 		..		++		##
 //EJm:
 :	
rG   r   r   r   r   r   r   rO   c                   #    [        USS9  [        USSS9  [        USSS9  [        USS5        [        USS5        [        X#5      n[	        U USSS	9I S h  vN n[        U5      S:w  a  [        S
5      e[        R                  " [        U [        UU[        S5      [        U5      [        U5      [        [        [!        US   5      SS9[        [!        US   5      SS9/S9S9["        S9I S h  vN 5      $  N N
7f)Nr   r   r   r   r   r   r   r   r   z1Failed to upload one or more images to comfy api.r   r   r   r   lastr   r   r   )r(   r)   r*   r'   r,   rT   r{   r   r   r   r	   r   r   r   r   r   r   r   )	rZ   r   r   r   r   r   r   stacked_input_imagesr   s	            rH   r    RunwayFirstLastFrameNode.execute  s     	1-!+$O!)tM#K@#Ivv>9+Q7 !	
 
 }"PQQ}} )%.%h/%e, 7;MRSDT@U`gh;MRSDT@U`fg! $@ 
 	

s%   AC=C9BC=0C;1	C=;C=r:   Nr   r:   rG   rH   r   r   K  sy    ;
 ;
z +
+
 [[+
 ;;	+

 +
 +
 +
 
+
 +
rG   r   c            
       |    \ rS rSr\S 5       r\ S
S\S\S\R                  S-  S\	R                  4S jj5       rS	rg)RunwayTextToImageNodei  c                 (   [         R                  " SSSS[         R                  R                  SSSSS	9[         R                  R                  S
[
         Vs/ s H  oR                  PM     snS9[         R                  R                  SSSS9/[         R                  R                  5       /[         R                  R                  [         R                  R                  [         R                  R                  /S[         R                  " SS9S9	$ s  snf )Nr   zRunway Text to Imagezpartner/image/Runwayz~Generate an image from a text prompt using Runway's Gen 4 model. You can also include reference image to guide the generation.r   Tr   r   r   r   r   reference_imagez0Optional reference image to guide the generation)r   optionalz{"type":"usd","usd":0.11}r   r   )r   r   r   r   r   r   valuer   r   r   r   r   r   r   )rZ   r   s     rH   r   #RunwayTextToImageNode.define_schema  s    yy+/+L 		"<	    6VW6VU[[6VW   %N!  $ ! 		..		++		##
 4A#
 #	
 Xs   DNr   r   r   rO   c                   #    [        USS9  S nUbB  [        USSS9  [        USS5        [        U USSS9I S h  vN n[	        [        US	   5      S
9/n[        U [        [        SS9[        [        U[        R                  UUS9S9I S h  vN n[        U UR                  [        S9I S h  vN nUR                   (       d  [#        S5      e[$        R&                  " [)        [+        U5      5      I S h  vN 5      $  N Ns NT N7f)Nr   r   r   r   r   r   r   r   r   )r   rr   rs   )r   r   r   referenceImagesru   r   z:Runway task succeeded but no image data found in response.)r(   r)   r*   r,   r   r   r2   r1   PATH_TEXT_TO_IMAGEr   r   r   
gen4_imagero   rz   AVERAGE_DURATION_T2I_SECONDSrQ   r{   r   r   r0   rY   )rZ   r   r   r   reference_imagesr   r|   r}   s           rH   r   RunwayTextToImageNode.execute  s     	1-  &%oRVW'H";%	# M !/3}Q7G3H IJ!( &8H4)!'' 0		
"
 

  ,; 
 

 $$YZZ}}#?@^_m@n#oopp9


 psG   7DC=ADC? D,D-AD4D5	D?DDDr:   ra   )r;   r<   r=   r>   r   r   r   r   r   r   r   r   rF   r:   rG   rH   r   r     sg    $
 $
L 
 /3	)q)q )q t+	)q
 
)q )qrG   r   zAbsolute time (seconds)zFraction of duration (0.0-1.0)c            
       |    \ rS rSr\S 5       r\ S
S\R                  S\S\	S-  S\
R                  4S jj5       rS	rg)RunwayAleph2KeyframeNodei  c                    [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  S[         R                  R                  [        [         R                  R                  S	S
S
SS[         R                  R                  SS9/5      [         R                  R                  [        [         R                  R                  SS
S
SS[         R                  R                  SS9/5      /SS9[         R                  " [        R                  5      R                  SSSS9/[         R                  " [        R                  5      R                  SS9/S9$ )Nr  zRunway Aleph2 Keyframer   a  Anchor a guidance image to a moment of the input (source) video, so Aleph2 steers the edit at that point of your footage. Connect this to the 'keyframes' input of the Runway Aleph2 Video to Video node; chain several together (up to 5) via the optional 'keyframes' input below.imagezDThe guidance image to apply at the chosen moment of the input video.r   timingseconds              >@皙?zGTime in seconds from start of the input video where this image applies.r   r   r   r   r   r   fraction      ?{Gz?zdWhere in the input video this image applies, as a fraction of its duration (0.0 = start, 1.0 = end).z6How to place this image on the input video's timeline.r   r   	keyframesTz2Optional earlier keyframes to chain with this one.r   r   r   r   r   r   r   r   r   )r   r   r   r   DynamicComboOption_TIMING_ABSOLUTEFloatr   r   _TIMING_FRACTIONCustomr   KEYFRAMEr   r   s    rH   r   &RunwayAleph2KeyframeNode.define_schema  sf   yy.1+'
 b   %%.., "$-,/(+(,),131A1A1H1H,u !/ !"
 .., "$.,/(+(+)-131A1A1H1H-^ !/ 	!"> UC & "F 		.11288!P 9 Q-\ YY~667>>K>XYm7
 7	
rG   Nr
  r  r  rO   c                    Ub  UR                  5       O	[        5       nUS   [        :X  a  [        [	        US   5      peO[
        [	        US   5      peUR                  [        XUS95        [        R                  " U5      $ )Nr  r  r  r
  moder   )
cloner   r  r#   floatr$   addr   r   r   )rZ   r
  r  r  chainr#  r   s          rH   r    RunwayAleph2KeyframeNode.executeQ  sn     &/%:	!@Y@[(///vi7H1I%*E&2D,E%		*OP}}U##rG   r:   ra   )r;   r<   r=   r>   r   r   r   r   dictr   r   r   r   rF   r:   rG   rH   r  r    sa    8
 8
t 
 7;	${{$ $ -t3	$
 
$ $rG   r  c            
       |    \ rS rSr\S 5       r\ S
S\R                  S\S\	S-  S\
R                  4S jj5       rS	rg)RunwayAleph2PromptImageNodeia  c                    [         R                  " SSSS[         R                  R                  SSS9[         R                  R                  S[         R                  R                  [        [         R                  R                  S	S
S
SS[         R                  R                  SS9/5      [         R                  R                  [        [         R                  R                  SS
S
SS[         R                  R                  SS9/5      /SS9[         R                  " [        R                  5      R                  SSSS9/[         R                  " [        R                  5      R                  SS9/S9$ )Nr+  zRunway Aleph2 Prompt Imager   a  Anchor a guidance image to a moment of the output (result) video, to guide what the edited video looks like at that point. Connect this to the 'prompt_images' input of the Runway Aleph2 Video to Video node; chain several together (up to 5) via the optional 'prompt_images' input below.r
  zEThe guidance image to place at the chosen moment of the output video.r   r   r  r  r  r  zHTime in seconds from start of the output video where this image applies.r  r  r  r  zeWhere in the output video this image applies, as a fraction of its duration (0.0 = start, 1.0 = end).z7How to place this image on the output video's timeline.r  prompt_imagesTz6Optional earlier prompt images to chain with this one.r  r  r  )r   r   r   r   r  r  r  r  r   r   r  r  r   PROMPT_IMAGEr   r   s    rH   r   )RunwayAleph2PromptImageNode.define_schemac  sg   yy15++
 c   %%.., "$-,/(+(,),131A1A1H1H,v !/ !"
 .., "$.,/(+(+)-131A1A1H1H-^ !/ 	!"> VC & "F 		.556<<#!T = Q-\ YY~::;BBP_B`am7
 7	
rG   Nr
  r   r-  rO   c                    Ub  UR                  5       O	[        5       nUS   [        :X  a  [        [	        US   5      peO[
        [	        US   5      peUR                  [        XUS95        [        R                  " U5      $ )Nr   r  r  r"  )
r$  r   r  r%   r%  r&   r&  r   r   r   )rZ   r
  r   r-  r'  r#  r   s          rH   r   #RunwayAleph2PromptImageNode.execute  sp     *7)B##%HdHfJ#335uXi=P7Q%4eHZ<P6Q%		-EERS}}U##rG   r:   ra   )r;   r<   r=   r>   r   r   r   r   r)  r   r   r   r   rF   r:   rG   rH   r+  r+  a  sb    8
 8
t 
 >B	${{$ $ 4d:	$
 
$ $rG   r+  c                       \ rS rSr\S 5       r\   SS\S\R                  S\	S\S\
S-  S	\S-  S
\R                  4S jj5       rSrg)RunwayAleph2VideoToVideoNodei  c                 &   [         R                  " SSSS[         R                  R                  SSSSS	9[         R                  R                  S
SS9[         R
                  R                  SSSSSS[         R                  R                  SS9[         R                  R                  SSS/SSS9[         R                  " [        R                  5      R                  SSSS9[         R                  " [        R                  5      R                  SSSS9/[         R                  R                  5       /[         R                  R                  [         R                  R                   [         R                  R"                  /S[         R$                  " SS9S9	$ ) Nr3  zRunway Aleph2 Video to Videor   a  Edit a video with a text prompt using Runway's Aleph2 model. Aleph2 transforms your footage (restyle, relight, add or remove elements, change the viewpoint) while keeping the original motion and timing; the output resolution matches the input video, which must be 2-30 seconds at 30 fps or lower. Optionally steer the edit with either keyframes (anchored to the input video) or prompt images (anchored to the output video) - use one or the other, not both.r   Tr   z?Describes what should appear in the output (1-1000 characters).r   videoz=Input video to edit. Must be 2-30 seconds at 30 fps or lower.r   r   r   r   r   r   r   public_figure_thresholdautolowz3Content moderation for recognizable public figures.)r   r   r   r  z|Guidance images anchored to the input video, from Aleph2 Keyframe nodes (up to 5). Use keyframes or prompt images, not both.r  r-  zGuidance images anchored to the output video, from Aleph2 Prompt Image nodes (up to 5). Use keyframes or prompt images, not both.z;{"type":"usd","usd": 0.4004, "format":{"suffix":"/second"}}r   r   )r   r   r   r   r   r   r   r   r   r  r   r  r.  r   r   r   r   r   r   r   s    rH   r   *RunwayAleph2VideoToVideoNode.define_schema  s   yy27+q 		"]	    [   "+/!#!1!1!8!88  	 -#UO!Q	   		.11288!@ 9  		.556<<#!@ = C'R ! 		..		++		##
 Vu=
 =	
rG   Nr   r5  r   r6  r  r-  rO   c                 d  ^#    [        USSS9  [        USSS9   [        UR                  5       5      nUb  US:  a  [        SUS	 S
35      eU(       a4  UR                  (       a#  U(       a  UR                  (       a  [        S5      eS m UR                  5       mS[        S[        SS 4U4S jjn[        X5      I S h  vN n	/ n
Ub  [        UR                  5      S:  a  [        S5      eUR                   H  n[        XR                  SS9I S h  vN nUR                  [        :X  a8  U" UR                  S5        U
R!                  [#        UR                  US95        Mk  U
R!                  [%        UR                  US95        M     / nUb  [        UR                  5      S:  a  [        S5      eUR                   H  n[        XR                  SS9I S h  vN nUR                  [&        :X  a'  U" UR                  S5        [)        UR                  S9nO[+        UR                  S9nUR!                  [-        XS95        M     [/        U [1        [2        SS9[4        [7        UU	U[9        US9U
=(       d    S U=(       d    S S9S 9I S h  vN n[;        XR<                  5      I S h  vN nUR>                  (       d  [        S!5      e[@        RB                  " [E        [G        U5      5      I S h  vN 5      $ ! [         a    S n GNf = f! [         a    S m GNf = f GNb GN GNM N N N;7f)"Nr   i  )r   
max_lengthg       @r  )min_durationmax_durationg(\>@zInput video frame rate (.2fz) fps) exceeds Aleph2's maximum of 30 fps.z;Aleph2 accepts either keyframes or prompt images, not both.r   labelrO   c                 L   > Tb   U TS-   :  a  [        U SU S STS S35      eg g )Ng-C6? r>  z$s exceeds the input video duration (zs).)r{   )r   r?  video_durations     rH   _check_seconds<RunwayAleph2VideoToVideoNode.execute.<locals>._check_seconds  sE    )env6M.M E7!E#;6Z[ijmZnnq!rss /N)rG      z$Aleph2 supports at most 5 keyframes.r   )r   zKeyframe timestamp)r  r   )atr   z(Aleph2 supports at most 5 prompt images.zPrompt image timestamp)timestampSeconds)positionPercentage)r   r   rr   rs   )publicFigureThreshold)r   videoUrir   contentModerationr  r   ru   rx   )$r(   r+   r%  get_frame_rate	Exceptionr{   itemsget_durationr   r.   rT   r-   r
  r#  r#   r   appendr   r   r%   r    r!   r   r2   r1   PATH_VIDEO_TO_VIDEOr   r   r"   ro   rz   rQ   r   r   r/   rV   )rZ   r   r5  r   r6  r  r-  fpsrC  r~   keyframe_modelsitem	image_urlprompt_image_modelsr   r|   r}   rB  s                    @rH   r   $RunwayAleph2VideoToVideoNode.execute  s     	1>	

	,,./C ?s[07Cy@ijkk)//-BUBUZ[['+	""//1N	t% 	t 	t 	t 33>>	VX 9??#a' !GHH!":3

Va"bb	99 55"4::/CD#**+Ftzz_h+ij#**+ATZZU^+_` ( >@$=&&'!+ !KLL%++":3

Va"bb	99 ;;"4::/GH<djjYH;tzzZH#**+BH+de , ") &9&I/$!""?Vm"n)1T/74	"
 
  ,C1D1DEE$$YZZ}}#?@^_m@n#ooppA  	C	  	"!N	" ? c c
 F ps   L0K; AL0L $L0?L! AL0L$CL0L'B2L0L*L0*L,+AL02L.3L0;LL0
LL0LL0LL0$L0'L0*L0,L0.L0r:   )r8  NN)r;   r<   r=   r>   r   r   r   r   r   r   r   r   r   r   r   rF   r:   rG   rH   r3  r3    s    >
 >
@  (-6:=AQqQq {{Qq 	Qq
 "%Qq -t3Qq 4d:Qq 
Qq QqrG   r3  c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)RunwayExtensioniF  rO   c                 T   #    [         [        [        [        [        [
        [        /$ 7fra   )r   r   r   r   r3  r  r+  )selfs    rH   get_node_listRunwayExtension.get_node_listG  s&      %'&!($'
 	
s   &(r:   N)r;   r<   r=   r>   r   listtyper   	ComfyNoder\  rF   r:   rG   rH   rY  rY  F  s)    	
T$r||*<%= 	
 	
rG   rY  c                     #    [        5       $ 7fra   )rY  r:   rG   rH   comfy_entrypointrb  T  s     s   ra   )Xr?   enumr   typing_extensionsr   comfy_api.latestr   r   r   r   comfy_api_nodes.apis.runwayr	   r
   r   rn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   comfy_api_nodes.utilr'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   ry   rQ  r  rm   AVERAGE_DURATION_I2V_SECONDSr   r  r   r8   rJ   rV   rY   r_  r`  r   ro   VideoFromFiler   r   r   r   r   r  r  r  r+  r3  rY  rb  r:   rG   rH   <module>rj     s    & A A       @     5 4 2 , ! " !  d   S$  -? C$J -? C$J  MQ
	bll	
&)
?BTz

  &*9	bll	9&9 d
9 	9([
",, [
|\
 \
~l
r|| l
^SqBLL Sql - 3 J$r|| J$ZJ$",, J$ZUq2<< Uqp
n 
 rG   