Skip to content

Commit

Permalink
* update rtsp doc
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed May 20, 2024
1 parent 5d597bd commit a85f561
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/doc/en/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ items:
label: Play video
- file: video/jpeg_streaming.md
label: JPEG stream
- file: video/rtsp.md
- file: video/rtsp_streaming.md
label: RTSP stream


Expand Down
71 changes: 71 additions & 0 deletions docs/doc/en/video/rtsp_streaming.md
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
2 changes: 1 addition & 1 deletion docs/doc/zh/sidebar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ items:
label: 播放视频
- file: video/jpeg_streaming.md
label: JPEG 串流
- file: video/rtsp.md
- file: video/rtsp_streaming.md
label: RTSP 串流


Expand Down
74 changes: 74 additions & 0 deletions docs/doc/zh/video/rtsp_streaming.md
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
2 changes: 1 addition & 1 deletion examples/vision/streaming/rtsp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from maix import time, rtsp, camera, image

server = rtsp.Rtsp()
cam = camera.Camera(2560, 1440, image.Format.FMT_YVU420SP)
server = rtsp.Rtsp()
server.bind_camera(cam)
server.start()

Expand Down

0 comments on commit a85f561

Please sign in to comment.