Configuring motion daemon
for low-latency MJPEG streaming

motion is an easy to use image capturer with motion detection. Also it is able to stream video from a camera to web as MJPEG stream. It is in Debian repos. But by default it is not configured for low latency.

Lowering the latency

One can use something like the following to decrease the latency of motion. (By default the config file is located in /etc/motion/motion.conf.)

daemon off
width 640
height 480
framerate 15
noise_tune off
#despeckle_filter EedDl
emulate_motion on
output_pictures off
quality 100
ffmpeg_output_movies off
stream_quality 100
stream_maxrate 15
stream_localhost off

For me this lowers the latency from about 3-5 secs to about 1 sec.

In this config i set width and height to ones supported by my camera (640 x 480). I hope it can decrease scaling. Also i set the frame rates to one supported by my camera (15). Also I disable filtering and motion detection.

But by my observation the stream_maxrate option is the real game changer here.