File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class Telly(lt.Thing):
1010 _stream_thread : threading .Thread
1111 _streaming : bool = False
1212 framerate : float = 1000
13+ frame_limit : int = 3
1314
1415 stream = lt .outputs .MJPEGStreamDescriptor ()
1516
@@ -33,8 +34,10 @@ def _make_images(self):
3334 jpegs .append (dest .getvalue ())
3435
3536 i = 0
36- while self ._streaming and i < len (jpegs ):
37- self .stream .add_frame (jpegs [i ], self ._labthings_blocking_portal )
37+ while self ._streaming and (i < self .frame_limit or self .frame_limit < 0 ):
38+ self .stream .add_frame (
39+ jpegs [i % len (jpegs )], self ._labthings_blocking_portal
40+ )
3841 time .sleep (1 / self .framerate )
3942 i = i + 1
4043 self .stream .stop (self ._labthings_blocking_portal )
@@ -65,4 +68,11 @@ def test_mjpeg_stream():
6568
6669
6770if __name__ == "__main__" :
68- test_mjpeg_stream ()
71+ import uvicorn
72+
73+ server = lt .ThingServer ()
74+ telly = Telly ()
75+ telly .framerate = 6
76+ telly .frame_limit = - 1
77+ server .add_thing (telly , "telly" )
78+ uvicorn .run (server .app , port = 5000 )
You can’t perform that action at this time.
0 commit comments