@@ -19,10 +19,11 @@ def __init__(self, **kwargs):
19
19
self .processed_audio_buffer = np .array ([], dtype = np .int16 )
20
20
21
21
async def warm_video (self ):
22
- dummy_video_inp = torch .randn (1 , 512 , 512 , 3 )
22
+ dummy_frame = av .VideoFrame ()
23
+ dummy_frame .side_data .input = torch .randn (1 , 512 , 512 , 3 )
23
24
24
25
for _ in range (WARMUP_RUNS ):
25
- self .client .put_video_input (dummy_video_inp )
26
+ self .client .put_video_input (dummy_frame )
26
27
await self .client .get_video_output ()
27
28
28
29
async def warm_audio (self ):
@@ -45,9 +46,10 @@ async def update_prompts(self, prompts: Union[Dict[Any, Any], List[Dict[Any, Any
45
46
await self .client .update_prompts ([prompts ])
46
47
47
48
async def put_video_frame (self , frame : av .VideoFrame ):
48
- inp_tensor = self .video_preprocess (frame )
49
- self .client .put_video_input (inp_tensor )
50
- await self .video_incoming_frames .put ((frame .pts , frame .time_base ))
49
+ frame .side_data .input = self .video_preprocess (frame )
50
+ frame .side_data .skipped = True
51
+ self .client .put_video_input (frame )
52
+ await self .video_incoming_frames .put (frame )
51
53
52
54
async def put_audio_frame (self , frame : av .AudioFrame ):
53
55
inp_np = self .audio_preprocess (frame )
@@ -71,12 +73,14 @@ def audio_postprocess(self, output: Union[torch.Tensor, np.ndarray]) -> av.Audio
71
73
72
74
async def get_processed_video_frame (self ):
73
75
# TODO: make it generic to support purely generative video cases
74
- pts , time_base = await self .video_incoming_frames .get ()
75
76
out_tensor = await self .client .get_video_output ()
77
+ frame = await self .video_incoming_frames .get ()
78
+ while frame .side_data .skipped :
79
+ frame = await self .video_incoming_frames .get ()
76
80
77
81
processed_frame = self .video_postprocess (out_tensor )
78
- processed_frame .pts = pts
79
- processed_frame .time_base = time_base
82
+ processed_frame .pts = frame . pts
83
+ processed_frame .time_base = frame . time_base
80
84
81
85
return processed_frame
82
86
0 commit comments