@@ -176,7 +176,11 @@ def on_track_subscribed(
176176 await subscriber_room .connect (url , subscriber_token )
177177 await publisher_room .connect (url , publisher_token )
178178
179- source = rtc .VideoSource (2 , 2 )
179+ # Use a real video resolution: WebRTC encoders (VP8/H.264) enforce a
180+ # 16x16 minimum and assert internally on smaller inputs, which would
181+ # crash the FFI process via panic=abort.
182+ frame_width , frame_height = 320 , 240
183+ source = rtc .VideoSource (frame_width , frame_height )
180184 track = rtc .LocalVideoTrack .create_video_track ("metadata-video" , source )
181185 packet_trailer_features = [
182186 rtc .PacketTrailerFeature .PTF_USER_TIMESTAMP ,
@@ -196,39 +200,20 @@ def on_track_subscribed(
196200
197201 video_stream = rtc .VideoStream .from_track (track = subscribed_track , capacity = 1 )
198202 frame = rtc .VideoFrame (
199- width = 2 ,
200- height = 2 ,
203+ width = frame_width ,
204+ height = frame_height ,
201205 type = rtc .VideoBufferType .RGBA ,
202- data = bytes (
203- [
204- 255 ,
205- 0 ,
206- 0 ,
207- 255 ,
208- 0 ,
209- 255 ,
210- 0 ,
211- 255 ,
212- 0 ,
213- 0 ,
214- 255 ,
215- 255 ,
216- 255 ,
217- 255 ,
218- 255 ,
219- 255 ,
220- ]
221- ),
206+ data = bytes ([255 , 0 , 0 , 255 ] * (frame_width * frame_height )),
222207 )
223208 metadata = rtc .FrameMetadata (user_timestamp = 123456789 , frame_id = 77 )
224209
225210 async def publish_frames ():
226- for _ in range (20 ):
211+ for _ in range (10 ):
227212 source .capture_frame (frame , metadata = metadata )
228- await asyncio .sleep (0.05 )
213+ await asyncio .sleep (0.2 )
229214
230215 publish_task = asyncio .create_task (publish_frames ())
231- event = await asyncio .wait_for (video_stream .__anext__ (), timeout = 5 .0 )
216+ event = await asyncio .wait_for (video_stream .__anext__ (), timeout = 10 .0 )
232217 await publish_task
233218
234219 assert event .metadata is not None
0 commit comments