logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

ustreamer - stream MJPEG video from any V4L2 device to the network

Author

       Maxim Devaev <mdevaev@gmail.com>

Bugs

       Please file any bugs and issues at https://github.com/pikvm/ustreamer/issues

Description

       µStreamer  (ustreamer)  is a lightweight and very quick server to stream MJPEG video from any V4L2 device
       to the network. All new browsers have native support of this video format, as well as most video  players
       such  as  mplayer,  VLC  etc.  µStreamer  is a part of the Pi-KVM project designed to stream VGA and HDMI
       screencast hardware data with the highest resolution and FPS possible.

Homepage

https://pikvm.org/

Name

       ustreamer - stream MJPEG video from any V4L2 device to the network

Options

Capturingoptions-d/dev/path, --device/dev/path
              Path to V4L2 device. Default: /dev/video0.

       -iN, --inputN
              Input channel. Default: 0.

       -rWxH, --resolutionWxH
              Initial image resolution. Default: 640x480.

       -mfmt, --formatfmt
              Image format.  Available: YUYV, UYVY, RGB565, RGB24, JPEG; default: YUYV.

       -astd, --tv-standardstd
              Force TV standard.  Available: PAL, NTSC, SECAM; default: disabled.

       -Imethod, --io-methodmethod
              Set  V4L2  IO  method  (see  kernel  documentation).  Changing  of this parameter may increase the
              performance. Or not.  Available: MMAP, USERPTR; default: MMAP.

       -fN, --desired-fpsN
              Desired FPS. Default: maximum possible.

       -zN, --min-frame-sizeN
              Drop frames smaller then this limit. Useful if the device  produces  small-sized  garbage  frames.
              Default: 128 bytes.

       -n, --persistent
              Don't re-initialize device on timeout. Default: disabled.

       -t, --dv-timings
              Enable  DV-timings  querying  and  events  processing  to  automatic  resolution  change. Default:
              disabled.

       -bN, --buffersN
              The number of buffers to receive data  from  the  device.  Each  buffer  may  processed  using  an
              independent thread.  Default: 2 (the number of CPU cores (but not more than 4) + 1).

       -wN, --workersN
              The  number of worker threads but not more than buffers.  Default: 1 (the number of CPU cores (but
              not more than 4)).

       -qN, --qualityN
              Set quality of JPEG encoding from 1 to 100 (best). Default: 80.  Note:  If  HW  encoding  is  used
              (JPEG  source  format selected), this parameter attempts to configure the camera or capture device
              hardware's internal encoder. It does not re-encode MJPEG to MJPEG to change the quality level  for
              sources that already output MJPEG.

       -ctype, --encodertype
              Use specified encoder. It may affect the number of workers.

              CPU ─ Software MJPEG encoding (default).

              HW ─ Use pre-encoded MJPEG frames directly from camera hardware.

              M2M-VIDEO ─ GPU-accelerated MJPEG encoding.

              M2M-IMAGE ─ GPU-accelerated JPEG encoding.

              NOOP ─ Don't compress MJPEG stream (do nothing).

       -gWxH,..., --glitched-resolutionsWxH,...
              It doesn't do anything. Still here for compatibility.

       -kpath, --blankpath
              Path  to  JPEG  file  that  will  be  shown  when the device is disconnected during the streaming.
              Default: black screen 640x480 with 'NO SIGNAL'.

       -Ksec, --last-as-blanksec
              Show the last frame received from the camera after it was disconnected, but no more than specified
              time (or endlessly if 0 is specified). If the device has not yet been online, display 'NO  SIGNAL'
              or  the  image  specified  by  option --blank. Note: currently this option has no effect on memory
              sinks. Default: disabled.

       -l, --slowdown
              Slowdown capturing to 1 FPS or less when no stream or sink clients are connected. Useful to reduce
              CPU consumption. Default: disabled.

       --device-timeoutsec
              Timeout for device querying. Default: 1.

       --device-error-delaysec
              Delay before trying to connect to the device again after an error (timeout for example).  Default:
              1.

       --m2m-device/dev/path
              Path to V4L2 mem-to-mem encoder device. Default: auto-select.

   Imagecontroloptions--image-default
              Reset all image settings below to default. Default: no change.

       --brightnessN, auto, default
              Set brightness. Default: no change.

       --contrastN, default
              Set contrast. Default: no change.

       --saturationN, default
              Set saturation. Default: no change.

       --hueN, auto, default
              Set hue. Default: no change.

       --gammaN, default
              Set gamma. Default: no change.

       --sharpnessN, default
              Set sharpness. Default: no change.

       --backlight-compensationN, default
              Set backlight compensation. Default: no change.

       --white-balanceN, auto, default
              Set white balance. Default: no change.

       --gainN, auto, default
              Set gain. Default: no change.

       --color-effectN, default
              Set color effect. Default: no change.

       --flip-vertical1, 0, default
              Set vertical flip. Default: no change.

       --flip-horizontal1, 0, default
              Set horizontal flip. Default: no change.

   HTTPserveroptions-saddress, --hostaddress
              Listen on Hostname or IP. Default: 127.0.0.1.

       -pN, --portN
              Bind to this TCP port. Default: 8080.

       -Upath, --unixpath
              Bind to UNIX domain socket. Default: disabled.

       -D, --unix-rm
              Try to remove old unix socket file before binding. default: disabled.

       -Mmode, --unix-modemode
              Set UNIX socket file permissions (like 777). Default: disabled.

       -S, --systemd
              Bind to systemd socket for socket activation. Required WITH_SYSTEMD feature. Default: disabled.

       --username
              HTTP basic auth user. Default: disabled.

       --passwdstr
              HTTP basic auth passwd. Default: empty.

       --staticpath
              Path  to dir with static files instead of embedded root index page. Symlinks are not supported for
              security reasons. Default: disabled.

       -eN, --drop-same-framesN
              Don't send identical frames to clients, but no more than specified number.  It  can  significantly
              reduce  the outgoing traffic, but will increase the CPU loading. Don't use this option with analog
              signal sources or webcams, it's useless. Default: disabled.

       -RWxH, --fake-resolutionWxH
              Override image resolution for the /state. Default: disabled.

       --tcp-nodelay
              Set TCP_NODELAY flag to the client /stream socket. Only for TCP socket.  Default: disabled.

       --allow-originstr
              Set Access-Control-Allow-Origin header. Default: disabled.

       --server-timeoutsec
              Timeout for client connections. Default: 10.

   JPEGsinkoptions
       With shared memory sink you can write a stream to a file. See ustreamer-dump(1) for more info.

       --sinkname
              Use the specified shared memory object to sink JPEG frames. Default: disabled.

       --sink-modemode
              Set JPEG sink permissions (like 777). Default: 660.

       --sink-rm
              Remove shared memory on stop. Default: disabled.

       --sink-client-ttlsec
              Client TTL. Default: 10.

       --sink-timeoutsec
              Timeout for lock. Default: 1.

   H264sinkoptions--h264-sinkname
              Use the specified shared memory object to sink H264 frames. Default: disabled.

       --h264-sink-modemode
              Set H264 sink permissions (like 777). Default: 660.

       --h264-sink-rm
              Remove shared memory on stop. Default: disabled.

       --h264-sink-client-ttlsec
              Client TTL. Default: 10.

       --h264-sink-timeoutsec
              Timeout for lock. Default: 1.

       --h264-bitratekbps
              H264 bitrate in Kbps. Default: 5000.

       --h264-gopN
              Intarval between keyframes. Default: 30.

       --h264-m2m-device/dev/path
              Path to V4L2 mem-to-mem encoder device. Default: auto-select.

   Processoptions--exit-on-parent-death
              Exit the program if the parent process is dead. Required HAS_PDEATHSIG feature. Default: disabled.

       --exit-on-no-clientssec
              Exit the program if there have been no stream or sink clients or any HTTP requests in the  last  N
              seconds. Default: 0 (disabled).

       --process-name-prefixstr
              Set  process  name  prefix  which  will  be  displayed  in  the  process list like 'str:ustreamer--blah-blah-blah'. Required WITH_SETPROCTITLE feature. Default: disabled.

       --notify-parent
              Send SIGUSR2 to the parent process when the stream parameters are  changed.  Checking  changes  is
              performed for the online flag and image resolution. Required WITH_SETPROCTITLE feature.

   GPIOoptions
       Available only if WITH_GPIO feature enabled.

       --gpio-device/dev/path
              Path to GPIO character device. Default: /dev/gpiochip0.

       --gpio-consumer-prefixstr
              Consumer prefix for GPIO outputs. Default: ustreamer.

       --gpio-prog-runningpin
              Set 1 on GPIO pin while µStreamer is running. Default: disabled.

       --gpio-stream-onlinepin
              Set 1 while streaming. Default: disabled.

       --gpio-has-http-clientspin
              Set 1 while stream has at least one client. Default: disabled.

   Loggingoptions--log-levelN
              Verbosity  level of messages from 0 (info) to 3 (debug). Enabling debugging messages can slow down
              the program.  Available levels: 0 (info), 1 (performance), 2 (verbose), 3 (debug).  Default: 0.

       --perf Enable performance messages (same as --log-level=1). Default: disabled.

       --verbose
              Enable verbose messages and lower (same as --log-level=2). Default: disabled.

       --debug
              Enable debug messages and lower (same as --log-level=3). Default: disabled.

       --force-log-colors
              Force color logging. Default: colored if stderr is a TTY.

       --no-log-colors
              Disable color logging. Default: ditto.

   Helpoptions-h, --help
              Print this text and exit.

       -v, --version
              Print version and exit.

       --features
              Print list of supported features.

See Also

ustreamer-dump(1)

Synopsis

ustreamer [OPTIONS]

Usage

       Without arguments, ustreamer will try to open /dev/video0 with 640x480 resolution and start streaming  on
       http://127.0.0.1:8080.  You  can override this behavior using parameters --device, --host and --port. For
       example, to stream to the world, run: ustreamer--device=/dev/video1--host=0.0.0.0--port=80

       Please note that since µStreamer v2.0  cross-domain  requests  were  disabled  by  default  for  security
       reasons. To enable the old behavior, use the option --allow-origin=\*.

       For example, the recommended way of running µStreamer with Auvidea B101 on a Raspberry Pi is:

       ustreamer\--format=uyvy\ # Device input format
              --encoder=m2m-image\ # Hardware encoding with V4L2 M2M intraface
              --workers=3\ # Maximum workers for V4L2 encoder
              --persistent\ # Don´t re-initialize device on timeout (for example when HDMI cable was disconnected)
              --dv-timings\ # Use DV-timings
              --drop-same-frames=30 # Save the traffic

       Please note that to use --drop-same-frames for different browsers you need to use some specific URL /stream parameters (see URL / for details).

       You can always view the full list of options with ustreamer--help. Some features may not be available on your platform. To find out which features are enabled, use ustreamer--features.

See Also