MjpegServer

class cscore.MjpegServer(*args, **kwargs)

Bases: VideoSink

A sink that acts as a MJPEG-over-HTTP network server.

Overloaded function.

  1. __init__(self: cscore._cscore.MjpegServer) -> None

  2. __init__(self: cscore._cscore.MjpegServer, name: str, listenAddress: str, port: int) -> None

Create a MJPEG-over-HTTP server sink.

Parameters:
  • name – Sink name (arbitrary unique identifier)

  • listenAddress – TCP listen address (empty string for all addresses)

  • port – TCP port number

  1. __init__(self: cscore._cscore.MjpegServer, name: str, port: int) -> None

Create a MJPEG-over-HTTP server sink.

Parameters:
  • name – Sink name (arbitrary unique identifier)

  • port – TCP port number

getListenAddress() str

Get the listen address of the server.

getPort() int

Get the port number of the server.

setCompression(quality: int) None

Set the compression for clients that don’t specify it.

Setting this will result in increased CPU usage for MJPEG source cameras as it will decompress and recompress the image instead of using the camera’s MJPEG image directly.

Parameters:

quality – JPEG compression quality (0-100), -1 for unspecified

setDefaultCompression(quality: int) None

Set the default compression used for non-MJPEG sources. If not set, 80 is used. This function has no effect on MJPEG source cameras; use SetCompression() instead to force recompression of MJPEG source images.

Parameters:

quality – JPEG compression quality (0-100)

setFPS(fps: int) None

Set the stream frames per second (FPS) for clients that don’t specify it.

It is not necessary to set this if it is the same as the source FPS.

Parameters:

fps – FPS, 0 for unspecified

setResolution(width: int, height: int) None

Set the stream resolution for clients that don’t specify it.

It is not necessary to set this if it is the same as the source resolution.

Setting this different than the source resolution will result in increased CPU usage, particularly for MJPEG source cameras, as it will decompress, resize, and recompress the image, instead of using the camera’s MJPEG image directly.

Parameters:
  • width – width, 0 for unspecified

  • height – height, 0 for unspecified