-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: MaixPy Video Streaming RTSP Push Streaming | ||
update: | ||
- date: 2024-05-20 | ||
author: lxowalle | ||
version: 1.0.0 | ||
content: Initial documentation | ||
--- | ||
|
||
## Introduction | ||
|
||
This document provides methods for pushing streaming camera image via RTSP | ||
|
||
## How to use | ||
|
||
```python | ||
from maix import time, rtsp, camera, image | ||
|
||
server = rtsp.Rtsp() | ||
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP) | ||
server.bind_camera(cam) | ||
server.start() | ||
|
||
print(server.get_url()) | ||
|
||
while True: | ||
time.sleep(1) | ||
``` | ||
|
||
Steps: | ||
|
||
1. Import the image、camera、image and rtsp modules: | ||
|
||
```python | ||
from maix import time, rtsp, camera, image | ||
``` | ||
|
||
2. Initialize the camera: | ||
|
||
```python | ||
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP) # Initialise camera, output resolution 2560x1440 NV21 format | ||
``` | ||
- Note that the RTSP module currently only supports the NV21 format, so the camera needs to be configured to output in NV21 format. | ||
|
||
3. Initialise and start the Rtsp object | ||
|
||
```python | ||
server = rtsp.Rtsp() | ||
server.bind_camera(cam) | ||
server.start() | ||
``` | ||
|
||
- ``server = rtsp.Rtsp()`` used to create an ``Rtsp`` object | ||
- `server.bind_camera(cam)` is used to bind a `Camera` object, after which the original `Camera` object can no longer be used. | ||
- `server.start()` is used to start the `rtsp` push stream. | ||
|
||
4. Print the URL of the current RTSP stream | ||
|
||
``python | ||
print(server.get_url()) | ||
`` | ||
|
||
- ``server.get_url()`` is used to get the ``playback address`` of ``RTSP``. | ||
|
||
6. Finished, after running the above code, you can play the video stream through [VLC](https://www.videolan.org/vlc/) software, the tested version of `VLC` is `3.0.20`. The default playback address is `rtsp://device ip:8554/live`. | ||
|
||
## OSD | ||
|
||
Drawing lines and frames via OSD | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: MaixPy 视频流 RTSP 推流 | ||
update: | ||
- date: 2024-05-20 | ||
author: lxowalle | ||
version: 1.0.0 | ||
content: 初版文档 | ||
--- | ||
|
||
## 简介 | ||
|
||
本文档提供通过RTSP推流摄像头画面的方法 | ||
|
||
## 使用方法 | ||
|
||
```python | ||
from maix import time, rtsp, camera, image | ||
|
||
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP) | ||
server = rtsp.Rtsp() | ||
server.bind_camera(cam) | ||
server.start() | ||
|
||
print(server.get_url()) | ||
|
||
while True: | ||
time.sleep(1) | ||
``` | ||
|
||
步骤: | ||
|
||
1. 导入time、rtsp、camera和image模块 | ||
|
||
```python | ||
from maix import time, rtsp, camera, image | ||
``` | ||
|
||
2. 初始化摄像头 | ||
|
||
```python | ||
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP) # 初始化摄像头,输出分辨率2560x1440 NV21格式 | ||
``` | ||
|
||
- 注意RTSP模块目前只支持NV21格式, 因此摄像头需要配置为NV21格式输出 | ||
|
||
|
||
3. 初始化并启动Rtsp对象 | ||
|
||
```python | ||
server = rtsp.Rtsp() | ||
server.bind_camera(cam) | ||
server.start() | ||
``` | ||
|
||
- `server = rtsp.Rtsp()`用来创建一个`Rtsp`对象 | ||
- `server.bind_camera(cam)`用来绑定一个`Camera`对象, 绑定后原`Camera`对象将不能再使用 | ||
- `server.start()`用来启动`rtsp`推流 | ||
|
||
4. 打印当前RTSP流的URL | ||
|
||
```python | ||
print(server.get_url()) | ||
``` | ||
|
||
- `server.get_url()`用来获取`RTSP`的`播放地址`。 | ||
|
||
6. 完成,运行上须代码后, 你可以通过[VLC](https://www.videolan.org/vlc/)软件播放视频流, 已测试的`VLC`版本是`3.0.20`. 默认播放地址为`rtsp://设备的ip:8554/live` | ||
|
||
|
||
## OSD | ||
|
||
通过OSD来实现画线与画框 | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters