ax-devil-rtsp 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. ax_devil_rtsp-0.1.0/LICENSE +21 -0
  2. ax_devil_rtsp-0.1.0/PKG-INFO +329 -0
  3. ax_devil_rtsp-0.1.0/README.md +302 -0
  4. ax_devil_rtsp-0.1.0/pyproject.toml +64 -0
  5. ax_devil_rtsp-0.1.0/setup.cfg +4 -0
  6. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/__init__.py +31 -0
  7. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/cli/__init__.py +10 -0
  8. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/cli/__main__.py +10 -0
  9. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/cli/main.py +379 -0
  10. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/deps.py +44 -0
  11. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/__init__.py +14 -0
  12. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/callbacks.py +269 -0
  13. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/client.py +140 -0
  14. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/diagnostics.py +109 -0
  15. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/pipeline.py +150 -0
  16. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/gstreamer/utils.py +112 -0
  17. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/logging.py +200 -0
  18. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/raw_socket/metadata_raw.py +301 -0
  19. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/rtsp_data_retrievers.py +609 -0
  20. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/setup_workarounds/__init__.py +70 -0
  21. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/setup_workarounds/libproxy_segfault.py +526 -0
  22. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp/utils.py +167 -0
  23. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/PKG-INFO +329 -0
  24. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/SOURCES.txt +26 -0
  25. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/dependency_links.txt +1 -0
  26. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/entry_points.txt +2 -0
  27. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/requires.txt +13 -0
  28. ax_devil_rtsp-0.1.0/src/ax_devil_rtsp.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rasmus Rynell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,329 @@
1
+ Metadata-Version: 2.4
2
+ Name: ax-devil-rtsp
3
+ Version: 0.1.0
4
+ Summary: Python library for RTSP streaming from Axis devices
5
+ Author-email: Rasmus Rynell <Rynell.Rasmus@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/rasmusrynell/ax-devil-rtsp
8
+ Project-URL: Repository, https://github.com/rasmusrynell/ax-devil-rtsp.git
9
+ Project-URL: Documentation, https://github.com/rasmusrynell/ax-devil-rtsp#readme
10
+ Project-URL: Bug Tracker, https://github.com/rasmusrynell/ax-devil-rtsp/issues
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: numpy>=1.20.0
15
+ Requires-Dist: opencv-python>=4.5.0
16
+ Requires-Dist: click>=8.0.0
17
+ Requires-Dist: rich>=13.9.4
18
+ Requires-Dist: urllib3>=2.5.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0; extra == "dev"
21
+ Requires-Dist: pytest-asyncio; extra == "dev"
22
+ Requires-Dist: pytest-cov; extra == "dev"
23
+ Requires-Dist: black; extra == "dev"
24
+ Requires-Dist: ruff; extra == "dev"
25
+ Requires-Dist: opencv-python>=4.5.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # ax-devil-rtsp
29
+
30
+ <div align="center">
31
+
32
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
+ [![Type Hints](https://img.shields.io/badge/Type%20Hints-Strict-brightgreen.svg)](https://www.python.org/dev/peps/pep-0484/)
35
+
36
+ A Python library for RTSP streaming from Axis cameras with video and AXIS Scene metadata support.
37
+
38
+ *The words 'AXIS Scene Metadata' is hereby called 'application data' in this project.*
39
+
40
+ See also: [ax-devil-device-api](https://github.com/rasmusrynell/ax-devil-device-api) and [ax-devil-mqtt](https://github.com/rasmusrynell/ax-devil-mqtt) for other Axis device management tools.
41
+
42
+ </div>
43
+
44
+ ---
45
+
46
+ ## ๐Ÿ“‹ Contents
47
+
48
+ - [Feature Overview](#-feature-overview)
49
+ - [Installation](#-installation)
50
+ - [Quick Start](#-quick-start)
51
+ - [Testing](#-testing)
52
+ - [Development Setup](#-development-setup)
53
+ - [License](#-license)
54
+
55
+ ---
56
+
57
+ ## ๐Ÿ” Feature Overview
58
+
59
+ <table>
60
+ <thead>
61
+ <tr>
62
+ <th>Feature</th>
63
+ <th>Description</th>
64
+ <th align="center">Python API</th>
65
+ </tr>
66
+ </thead>
67
+ <tbody>
68
+ <tr>
69
+ <td><b>๐Ÿ”„ Combined Streaming</b></td>
70
+ <td>Simultaneous video and application data streaming (default)</td>
71
+ <td align="center"><code>RtspDataRetriever</code></td>
72
+ </tr>
73
+ <tr>
74
+ <td><b>๐Ÿ“น Video Only</b></td>
75
+ <td>Stream video frames without application data</td>
76
+ <td align="center"><code>RtspVideoDataRetriever</code></td>
77
+ </tr>
78
+ <tr>
79
+ <td><b>๐Ÿ“Š Application Data (AXIS Scene Metadata) Only</b></td>
80
+ <td>Stream scene application data without video</td>
81
+ <td align="center"><code>RtspApplicationDataRetriever</code></td>
82
+ </tr>
83
+ <tr>
84
+ <td><b>โšก Real-time Processing</b></td>
85
+ <td>Frame-by-frame processing with custom callbacks</td>
86
+ <td align="center"><code>on_video_data</code></td>
87
+ </tr>
88
+ <tr>
89
+ <td><b>๐ŸŽฏ RTP Extension Data</b></td>
90
+ <td>Access to ONVIF RTP extension data and timing information (enabled by default)</td>
91
+ <td align="center"><code>rtp_ext=True</code></td>
92
+ </tr>
93
+ <tr>
94
+ <td><b>๐Ÿ› ๏ธ Axis URL Builder</b></td>
95
+ <td>Utility for constructing Axis-compatible RTSP URLs</td>
96
+ <td align="center"><code>build_axis_rtsp_url</code></td>
97
+ </tr>
98
+ </tbody>
99
+ </table>
100
+
101
+ ---
102
+
103
+ ## ๐Ÿ“ฆ Installation
104
+
105
+ ```bash
106
+ pip install ax-devil-rtsp
107
+ ```
108
+
109
+ ### System Dependencies
110
+
111
+ On Linux, this library requires system packages for PyGObject and GStreamer. If they're missing, you'll see clear error messages with installation instructions.
112
+
113
+ **Quick setup (Ubuntu/Debian):**
114
+ ```bash
115
+ # Check what's missing
116
+ python tools/dep.py --check
117
+
118
+ # Get installation commands
119
+ python tools/dep.py --install
120
+ ```
121
+
122
+ ---
123
+
124
+ ## ๐Ÿš€ Quick Start
125
+
126
+ ### Python API
127
+
128
+ ```python
129
+ from ax_devil_rtsp import RtspDataRetriever, build_axis_rtsp_url
130
+ from multiprocessing import freeze_support
131
+ import time
132
+
133
+ # Define callback functions
134
+ def on_video_data(payload):
135
+ frame = payload["data"]
136
+ diagnostics = payload["diagnostics"]
137
+ print(f"Video frame: {frame.shape}, {diagnostics}")
138
+
139
+ def on_application_data(payload):
140
+ xml_data = payload["data"]
141
+ diagnostics = payload["diagnostics"]
142
+ print(f"Application data: {len(xml_data)} bytes, {diagnostics}")
143
+
144
+ def on_error(payload):
145
+ print(f"Error: {payload['message']}")
146
+
147
+ def main():
148
+ # Build the RTSP URL or supply one directly
149
+ # rtsp_url = "rtsp://username:password@192.168.1.90/axis-media/media.amp?analytics=polygon"
150
+ rtsp_url = build_axis_rtsp_url(
151
+ ip="192.168.1.90",
152
+ username="username",
153
+ password="password",
154
+ video_source=1,
155
+ get_video_data=True,
156
+ get_application_data=True,
157
+ rtp_ext=True, # Enable RTP extension data
158
+ resolution="640x480",
159
+ )
160
+
161
+ retriever = RtspDataRetriever(
162
+ rtsp_url=rtsp_url,
163
+ on_video_data=on_video_data,
164
+ on_application_data=on_application_data,
165
+ on_error=on_error,
166
+ latency=100,
167
+ )
168
+
169
+ # Use context manager for automatic cleanup
170
+ with retriever:
171
+ print("Streaming... Press Ctrl+C to stop")
172
+ while True:
173
+ time.sleep(0.1)
174
+
175
+ if __name__ == "__main__":
176
+ freeze_support() # Needed on Windows when multiprocessing start method is 'spawn'
177
+ main()
178
+ ```
179
+ > **Note**
180
+ >
181
+ > Because `ax-devil-rtsp` forces the multiprocessing start method to `'spawn'`,
182
+ > your script's entry point must be guarded with
183
+ > `if __name__ == "__main__":` (as shown above). On Windows also call
184
+ > `multiprocessing.freeze_support()` before starting the retriever.
185
+
186
+ #### Video-only and application-data-only
187
+
188
+ ```python
189
+ from ax_devil_rtsp import (
190
+ RtspVideoDataRetriever,
191
+ RtspApplicationDataRetriever,
192
+ build_axis_rtsp_url,
193
+ )
194
+
195
+ # Video-only
196
+ video_url = build_axis_rtsp_url(
197
+ ip="192.168.1.90",
198
+ username="username",
199
+ password="password",
200
+ video_source=1,
201
+ get_video_data=True,
202
+ get_application_data=False,
203
+ rtp_ext=True,
204
+ )
205
+ with RtspVideoDataRetriever(
206
+ rtsp_url=video_url,
207
+ on_video_data=lambda p: print(p["diagnostics"]),
208
+ ):
209
+ ...
210
+
211
+ # Application data only
212
+ app_url = build_axis_rtsp_url(
213
+ ip="192.168.1.90",
214
+ username="username",
215
+ password="password",
216
+ video_source=1,
217
+ get_video_data=False,
218
+ get_application_data=True,
219
+ rtp_ext=True,
220
+ )
221
+ with RtspApplicationDataRetriever(
222
+ rtsp_url=app_url,
223
+ on_application_data=lambda p: print(len(p["data"]))
224
+ ):
225
+ ...
226
+
227
+ ### CLI Usage
228
+
229
+ The CLI offers two subcommands:
230
+
231
+ - `device` builds the RTSP URL from device details like IP address and
232
+ credentials.
233
+ - `url` is for when you already have a complete RTSP URL. Options that modify
234
+ the URL (for example `--resolution` or `--rtp-ext`) are only valid with the
235
+ `device` command.
236
+
237
+ **Basic Usage (streams both video and application data):**
238
+ ```bash
239
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret
240
+ ```
241
+
242
+ **Using a complete RTSP URL:**
243
+ ```bash
244
+ ax-devil-rtsp url "rtsp://admin:secret@192.168.1.90/axis-media/media.amp?analytics=polygon"
245
+ ```
246
+
247
+ **Common Options:**
248
+ ```bash
249
+ # Custom resolution
250
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret \
251
+ --resolution 1280x720
252
+
253
+ # Different camera source
254
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --source 2
255
+ ```
256
+
257
+ **Specialized Modes:**
258
+ ```bash
259
+ # Video only (no application data overlay)
260
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --only-video
261
+
262
+ # Application data only (no video window)
263
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --only-application-data
264
+
265
+ # Disable RTP extension data
266
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --no-rtp-ext
267
+ ```
268
+
269
+ For demo processing and lifecycle control, see: `--enable-video-processing`, `--brightness-adjustment`, and `--manual-lifecycle` (run `ax-devil-rtsp device --help`).
270
+
271
+ ### Environment Variables (Optional)
272
+
273
+ ```bash
274
+ export AX_DEVIL_TARGET_ADDR=192.168.1.90
275
+ export AX_DEVIL_TARGET_USER=admin
276
+ export AX_DEVIL_TARGET_PASS=secret
277
+ export AX_DEVIL_USAGE_CLI=safe # Set to "unsafe" to skip SSL verification
278
+ ```
279
+ Set these variables to avoid passing `--ip`, `--username`, or `--password` each
280
+ time you invoke the `device` command.
281
+ `AX_DEVIL_USAGE_CLI` is shared with related `ax-devil-*` tools and kept here for consistency.
282
+
283
+ ---
284
+
285
+ ## ๐Ÿงช Testing
286
+
287
+ ```bash
288
+ # Unit tests
289
+ pytest tests/unit/ -v
290
+
291
+ # Integration tests (local test servers)
292
+ pytest tests/integration/ -v
293
+
294
+ # Integration tests (real camera)
295
+ USE_REAL_CAMERA=true AX_DEVIL_TARGET_ADDR=192.168.1.90 pytest tests/integration/ -v
296
+ ```
297
+
298
+ ---
299
+
300
+ > Note on GI/GStreamer
301
+ >
302
+ > On Linux, `PyGObject` and GStreamer are system packages. Install them with your distro package manager before using this library (see Development Setup below). If they are missing, the library will show an error with install instructions.
303
+
304
+
305
+ ### Python Environment
306
+
307
+ ```bash
308
+ python3 -m venv .venv
309
+ source .venv/bin/activate
310
+ pip install -e .[dev]
311
+ ```
312
+
313
+ ### Helper Scripts
314
+
315
+ - `tools/dep.py`: Unified dependency management tool
316
+ - Check dependencies: `python tools/dep.py --check`
317
+ - Get install commands (Ubuntu/Debian): `python tools/dep.py --install`
318
+
319
+ ---
320
+
321
+ ## ๐Ÿ“„ License
322
+
323
+ MIT License - See LICENSE file for details.
324
+
325
+ ---
326
+
327
+ ## โš ๏ธ Disclaimer
328
+
329
+ This project is independent and not affiliated with Axis Communications AB. For official resources, visit [Axis developer documentation](https://developer.axis.com/).
@@ -0,0 +1,302 @@
1
+ # ax-devil-rtsp
2
+
3
+ <div align="center">
4
+
5
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Type Hints](https://img.shields.io/badge/Type%20Hints-Strict-brightgreen.svg)](https://www.python.org/dev/peps/pep-0484/)
8
+
9
+ A Python library for RTSP streaming from Axis cameras with video and AXIS Scene metadata support.
10
+
11
+ *The words 'AXIS Scene Metadata' is hereby called 'application data' in this project.*
12
+
13
+ See also: [ax-devil-device-api](https://github.com/rasmusrynell/ax-devil-device-api) and [ax-devil-mqtt](https://github.com/rasmusrynell/ax-devil-mqtt) for other Axis device management tools.
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## ๐Ÿ“‹ Contents
20
+
21
+ - [Feature Overview](#-feature-overview)
22
+ - [Installation](#-installation)
23
+ - [Quick Start](#-quick-start)
24
+ - [Testing](#-testing)
25
+ - [Development Setup](#-development-setup)
26
+ - [License](#-license)
27
+
28
+ ---
29
+
30
+ ## ๐Ÿ” Feature Overview
31
+
32
+ <table>
33
+ <thead>
34
+ <tr>
35
+ <th>Feature</th>
36
+ <th>Description</th>
37
+ <th align="center">Python API</th>
38
+ </tr>
39
+ </thead>
40
+ <tbody>
41
+ <tr>
42
+ <td><b>๐Ÿ”„ Combined Streaming</b></td>
43
+ <td>Simultaneous video and application data streaming (default)</td>
44
+ <td align="center"><code>RtspDataRetriever</code></td>
45
+ </tr>
46
+ <tr>
47
+ <td><b>๐Ÿ“น Video Only</b></td>
48
+ <td>Stream video frames without application data</td>
49
+ <td align="center"><code>RtspVideoDataRetriever</code></td>
50
+ </tr>
51
+ <tr>
52
+ <td><b>๐Ÿ“Š Application Data (AXIS Scene Metadata) Only</b></td>
53
+ <td>Stream scene application data without video</td>
54
+ <td align="center"><code>RtspApplicationDataRetriever</code></td>
55
+ </tr>
56
+ <tr>
57
+ <td><b>โšก Real-time Processing</b></td>
58
+ <td>Frame-by-frame processing with custom callbacks</td>
59
+ <td align="center"><code>on_video_data</code></td>
60
+ </tr>
61
+ <tr>
62
+ <td><b>๐ŸŽฏ RTP Extension Data</b></td>
63
+ <td>Access to ONVIF RTP extension data and timing information (enabled by default)</td>
64
+ <td align="center"><code>rtp_ext=True</code></td>
65
+ </tr>
66
+ <tr>
67
+ <td><b>๐Ÿ› ๏ธ Axis URL Builder</b></td>
68
+ <td>Utility for constructing Axis-compatible RTSP URLs</td>
69
+ <td align="center"><code>build_axis_rtsp_url</code></td>
70
+ </tr>
71
+ </tbody>
72
+ </table>
73
+
74
+ ---
75
+
76
+ ## ๐Ÿ“ฆ Installation
77
+
78
+ ```bash
79
+ pip install ax-devil-rtsp
80
+ ```
81
+
82
+ ### System Dependencies
83
+
84
+ On Linux, this library requires system packages for PyGObject and GStreamer. If they're missing, you'll see clear error messages with installation instructions.
85
+
86
+ **Quick setup (Ubuntu/Debian):**
87
+ ```bash
88
+ # Check what's missing
89
+ python tools/dep.py --check
90
+
91
+ # Get installation commands
92
+ python tools/dep.py --install
93
+ ```
94
+
95
+ ---
96
+
97
+ ## ๐Ÿš€ Quick Start
98
+
99
+ ### Python API
100
+
101
+ ```python
102
+ from ax_devil_rtsp import RtspDataRetriever, build_axis_rtsp_url
103
+ from multiprocessing import freeze_support
104
+ import time
105
+
106
+ # Define callback functions
107
+ def on_video_data(payload):
108
+ frame = payload["data"]
109
+ diagnostics = payload["diagnostics"]
110
+ print(f"Video frame: {frame.shape}, {diagnostics}")
111
+
112
+ def on_application_data(payload):
113
+ xml_data = payload["data"]
114
+ diagnostics = payload["diagnostics"]
115
+ print(f"Application data: {len(xml_data)} bytes, {diagnostics}")
116
+
117
+ def on_error(payload):
118
+ print(f"Error: {payload['message']}")
119
+
120
+ def main():
121
+ # Build the RTSP URL or supply one directly
122
+ # rtsp_url = "rtsp://username:password@192.168.1.90/axis-media/media.amp?analytics=polygon"
123
+ rtsp_url = build_axis_rtsp_url(
124
+ ip="192.168.1.90",
125
+ username="username",
126
+ password="password",
127
+ video_source=1,
128
+ get_video_data=True,
129
+ get_application_data=True,
130
+ rtp_ext=True, # Enable RTP extension data
131
+ resolution="640x480",
132
+ )
133
+
134
+ retriever = RtspDataRetriever(
135
+ rtsp_url=rtsp_url,
136
+ on_video_data=on_video_data,
137
+ on_application_data=on_application_data,
138
+ on_error=on_error,
139
+ latency=100,
140
+ )
141
+
142
+ # Use context manager for automatic cleanup
143
+ with retriever:
144
+ print("Streaming... Press Ctrl+C to stop")
145
+ while True:
146
+ time.sleep(0.1)
147
+
148
+ if __name__ == "__main__":
149
+ freeze_support() # Needed on Windows when multiprocessing start method is 'spawn'
150
+ main()
151
+ ```
152
+ > **Note**
153
+ >
154
+ > Because `ax-devil-rtsp` forces the multiprocessing start method to `'spawn'`,
155
+ > your script's entry point must be guarded with
156
+ > `if __name__ == "__main__":` (as shown above). On Windows also call
157
+ > `multiprocessing.freeze_support()` before starting the retriever.
158
+
159
+ #### Video-only and application-data-only
160
+
161
+ ```python
162
+ from ax_devil_rtsp import (
163
+ RtspVideoDataRetriever,
164
+ RtspApplicationDataRetriever,
165
+ build_axis_rtsp_url,
166
+ )
167
+
168
+ # Video-only
169
+ video_url = build_axis_rtsp_url(
170
+ ip="192.168.1.90",
171
+ username="username",
172
+ password="password",
173
+ video_source=1,
174
+ get_video_data=True,
175
+ get_application_data=False,
176
+ rtp_ext=True,
177
+ )
178
+ with RtspVideoDataRetriever(
179
+ rtsp_url=video_url,
180
+ on_video_data=lambda p: print(p["diagnostics"]),
181
+ ):
182
+ ...
183
+
184
+ # Application data only
185
+ app_url = build_axis_rtsp_url(
186
+ ip="192.168.1.90",
187
+ username="username",
188
+ password="password",
189
+ video_source=1,
190
+ get_video_data=False,
191
+ get_application_data=True,
192
+ rtp_ext=True,
193
+ )
194
+ with RtspApplicationDataRetriever(
195
+ rtsp_url=app_url,
196
+ on_application_data=lambda p: print(len(p["data"]))
197
+ ):
198
+ ...
199
+
200
+ ### CLI Usage
201
+
202
+ The CLI offers two subcommands:
203
+
204
+ - `device` builds the RTSP URL from device details like IP address and
205
+ credentials.
206
+ - `url` is for when you already have a complete RTSP URL. Options that modify
207
+ the URL (for example `--resolution` or `--rtp-ext`) are only valid with the
208
+ `device` command.
209
+
210
+ **Basic Usage (streams both video and application data):**
211
+ ```bash
212
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret
213
+ ```
214
+
215
+ **Using a complete RTSP URL:**
216
+ ```bash
217
+ ax-devil-rtsp url "rtsp://admin:secret@192.168.1.90/axis-media/media.amp?analytics=polygon"
218
+ ```
219
+
220
+ **Common Options:**
221
+ ```bash
222
+ # Custom resolution
223
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret \
224
+ --resolution 1280x720
225
+
226
+ # Different camera source
227
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --source 2
228
+ ```
229
+
230
+ **Specialized Modes:**
231
+ ```bash
232
+ # Video only (no application data overlay)
233
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --only-video
234
+
235
+ # Application data only (no video window)
236
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --only-application-data
237
+
238
+ # Disable RTP extension data
239
+ ax-devil-rtsp device --ip 192.168.1.90 --username admin --password secret --no-rtp-ext
240
+ ```
241
+
242
+ For demo processing and lifecycle control, see: `--enable-video-processing`, `--brightness-adjustment`, and `--manual-lifecycle` (run `ax-devil-rtsp device --help`).
243
+
244
+ ### Environment Variables (Optional)
245
+
246
+ ```bash
247
+ export AX_DEVIL_TARGET_ADDR=192.168.1.90
248
+ export AX_DEVIL_TARGET_USER=admin
249
+ export AX_DEVIL_TARGET_PASS=secret
250
+ export AX_DEVIL_USAGE_CLI=safe # Set to "unsafe" to skip SSL verification
251
+ ```
252
+ Set these variables to avoid passing `--ip`, `--username`, or `--password` each
253
+ time you invoke the `device` command.
254
+ `AX_DEVIL_USAGE_CLI` is shared with related `ax-devil-*` tools and kept here for consistency.
255
+
256
+ ---
257
+
258
+ ## ๐Ÿงช Testing
259
+
260
+ ```bash
261
+ # Unit tests
262
+ pytest tests/unit/ -v
263
+
264
+ # Integration tests (local test servers)
265
+ pytest tests/integration/ -v
266
+
267
+ # Integration tests (real camera)
268
+ USE_REAL_CAMERA=true AX_DEVIL_TARGET_ADDR=192.168.1.90 pytest tests/integration/ -v
269
+ ```
270
+
271
+ ---
272
+
273
+ > Note on GI/GStreamer
274
+ >
275
+ > On Linux, `PyGObject` and GStreamer are system packages. Install them with your distro package manager before using this library (see Development Setup below). If they are missing, the library will show an error with install instructions.
276
+
277
+
278
+ ### Python Environment
279
+
280
+ ```bash
281
+ python3 -m venv .venv
282
+ source .venv/bin/activate
283
+ pip install -e .[dev]
284
+ ```
285
+
286
+ ### Helper Scripts
287
+
288
+ - `tools/dep.py`: Unified dependency management tool
289
+ - Check dependencies: `python tools/dep.py --check`
290
+ - Get install commands (Ubuntu/Debian): `python tools/dep.py --install`
291
+
292
+ ---
293
+
294
+ ## ๐Ÿ“„ License
295
+
296
+ MIT License - See LICENSE file for details.
297
+
298
+ ---
299
+
300
+ ## โš ๏ธ Disclaimer
301
+
302
+ This project is independent and not affiliated with Axis Communications AB. For official resources, visit [Axis developer documentation](https://developer.axis.com/).