From 5e91226f08a7f5eb256da05e50c6ae8c04e8a337 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Tue, 2 Jul 2024 18:05:49 +0800 Subject: [PATCH] * optimize rtmp demo --- examples/vision/streaming/rtmp_stream.py | 15 +++++++++++++++ projects/app_rtmp_live/main.py | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 examples/vision/streaming/rtmp_stream.py diff --git a/examples/vision/streaming/rtmp_stream.py b/examples/vision/streaming/rtmp_stream.py new file mode 100644 index 0000000..0171d85 --- /dev/null +++ b/examples/vision/streaming/rtmp_stream.py @@ -0,0 +1,15 @@ +from maix import camera, time, app, rtmp, image + +cam = camera.Camera(320, 240, image.Format.FMT_YVU420SP) + +host="192.168.0.30" +port=1935 +app_name="live" +stream_name="stream" +client = rtmp.Rtmp(host, port, app_name, stream_name) +client.bind_camera(cam) +client.start() + +print(f"rtmp://{host}:{port}/{app_name}/{stream_name}") +while not app.need_exit(): + time.sleep(1) \ No newline at end of file diff --git a/projects/app_rtmp_live/main.py b/projects/app_rtmp_live/main.py index 48cb3bd..868fe3a 100755 --- a/projects/app_rtmp_live/main.py +++ b/projects/app_rtmp_live/main.py @@ -128,7 +128,7 @@ def parse_url(url): base_img.draw_string(0, int(base_img.height() * 0.70), "URL:", color, 2) base_img.draw_string(url_x, int(base_img.height() * 0.70) + str_height_2 + 10, global_url, color) - box = [20, 20, img_exit.width(), img_exit.height()] + box = [20, 15, img_exit.width(), img_exit.height()] if touch_box(t, box, 20): base_img.draw_image(box[0], box[1], img_exit_touch) need_exit = True @@ -228,7 +228,7 @@ def parse_url(url): base_img.draw_string(str_rtmp_is_running_x, int(base_img.height() * 0.7), str_rtmp_is_running3, color, 2) need_exit = False - box = [20, 20, img_exit.width(), img_exit.height()] + box = [20, 15, img_exit.width(), img_exit.height()] if touch_box(t, box, 20): base_img.draw_image(box[0], box[1], img_exit_touch) need_exit = True