fetch(streamUrl, headers: 'Authorization': Basic $auth ) .then(response => const reader = response.body.getReader(); let boundary = ''; let buffer = '';
Axis cameras often use dedicated hardware JPEG encoders, allowing minimal CPU load even at high resolutions.
http://192.168.0.90/axis-cgi/mjpg/video.cgi?resolution=640x480&compression=30&fps=15&camera=1
http://192.168.1.100/axis-cgi/mjpg/video.cgi?resolution=1280x720&fps=10&compression=25&clock=1&text=Front%20Door axis cgi mjpg
Many Axis cameras are configured to require a username and password. In such cases, a request to video.cgi will return an HTTP 401 Unauthorized status. Axis cameras typically use HTTP Digest Authentication, which is more secure than Basic Authentication but requires a multi-step "challenge-response" process from the client.
Integrating live video into custom software applications, automation scripts, or web dashboards requires a reliable, lightweight streaming protocol. For developers working with Axis Communications network cameras, the native offers a robust solution. By leveraging Axis Common Gateway Interface (CGI) scripts, you can pull high-quality Motion JPEG (MJPEG) streams directly from hardware without the overhead of heavy media servers or complex external SDKs.
Source: Axis Developer Stage
| Parameter | Description | Example | |-----------|-------------|---------| | resolution | Width x Height | resolution=640x480 | | fps | Frames per second (camera max allowed) | fps=15 | | compression | JPEG quality (0-100, 100=best) | compression=30 | | camera | Select camera (for multi-sensor or PTZ) | camera=1 | | clock | Overlay timestamp | clock=1 | | text | Custom text overlay | text=My%20Stream | | date | Show date | date=1 | | quad | Apply quad view if supported | quad=1 | | rect | Crop region (x,y,w,h) | rect=100,100,400,300 | | rotation | Rotate image (0, 90, 180, 270) | rotation=90 | | mirror | Mirror image | mirror=1 |
Minimal processing time makes it ideal for real-time PTZ control.
. This CGI script generates a continuous stream of JPEG images that are delivered over HTTP, making it natively compatible with most modern web browsers and media players. The basic syntax for the stream URL is: fetch(streamUrl, headers: 'Authorization': Basic $auth )
Home Assistant can consume an Axis MJPEG stream with the generic_camera platform:
Axis cameras will likely retain the axis-cgi/mjpg/video.cgi endpoint for the foreseeable future to support the vast number of legacy systems that depend on it. It remains a crucial tool for developers integrating with older applications or building simple, proof-of-concept viewers.
Clients do not need heavy processing power to decode an MJPEG stream compared to complex codecs like H.265. Axis cameras typically use HTTP Digest Authentication, which
Use: