OctoPrint consuming anywhere from 30-60Mb/s on the network, sometimes higher

Camera model
Raspberry Pi Camera Module 3 - Wide

What is the problem?
I noticed a lot of latency and lagging on my home network recently and begin to look into things consuming large amounts of bandwidth. I found that OctoPrint is on average consuming anywhere from 30-60Mb/s in uploaded data to somewhere. In some cases this number jumps as high as 200-300Mb/s. Even if the stream from the camera were 100% RAW I wouldn't believe it would take that much data. Trying to determine what's going on.

What did you already try to solve it?

Haven't done anything to solve yet, this is information gathering to see if anyone else is experiencing this.

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)

NetHogs version 0.8.5-2+b1

    PID USER     PROGRAM                                                                                   DEV        SENT      RECEIVED
    463 pi       /home/pi/oprint/bin/python                                                                lo          0.917       0.000 KB/sec
    875 haproxy  /usr/sbin/haproxy                                                                         lo          2.578       0.000 KB/sec
    604 root     ./mjpg_streamer                                                                           lo       3103.294       0.000 KB/sec
      ? root     unknown TCP                                                                                           0.000       0.000 KB/sec

  TOTAL                                                                                                             3106.789       0.000 KB/sec
Starting up webcamDaemon...

--- Configuration: ----------------------------
cfg_file:      /boot/octopi.txt
camera:        libcamera
usb options:   -r 640x480 -f 10
raspi options: -fps 10
libcamera options: -r FHD -f 30
http options:  -w ./www-octopi -n

Explicitly set USB device:
-----------------------------------------------

Found video devices:
/dev/video0
/dev/video1
/dev/video10
/dev/video11
/dev/video12
/dev/video13
/dev/video14
/dev/video15
/dev/video16
/dev/video18
/dev/video19
/dev/video20
/dev/video21
/dev/video22
/dev/video23
/dev/video31
config file='/boot/octopi.txt':Starting MJPG-streamer with video device: libcamera
<13>Jan 21 03:00:00 root: Starting Libcamera camera
Checking for VL805 (Raspberry Pi 4)...
  - It seems that you don't have VL805 (Raspberry Pi 4).
    There should be no problems with USB (a.k.a. select() timeout)
Running ./mjpg_streamer -o output_http.so -w ./www-octopi -n -i input_libcamera.so -r FHD -f 30
MJPG Streamer Version: git rev: 290776e2d59ecf4589ffe15800e1ccfe17dc07e7
 i: Desired Resolution: 1920 x 1280
[0:00:09.857393751] [604]  INFO Camera camera_manager.cpp:299 libcamera v0.0.0+4135-f8a5e271
[0:00:09.978045362] [639]  INFO RPI raspberrypi.cpp:1425 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0
 o: www-folder-path......: ./www-octopi/
 o: HTTP TCP port........: 8080
 o: HTTP Listen Address..: (null)
 o: username:password....: disabled
 o: commands.............: disabled
Configuring still capture...
Still capture setup complete
[0:00:09.985407659] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:00:09.986317177] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Done bringing up all configured video devices
Configuring still capture...
Still capture setup complete
[0:03:27.854648544] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:03:27.855540427] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:03:28.522906204] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:03:28.524185788] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:03:42.337094811] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:03:42.337955010] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:03:43.017868654] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:03:43.027037453] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:05:04.883339263] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:05:04.884398858] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:05:05.551031100] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:05:05.574723577] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:11:35.535303368] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:11:35.538669440] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:11:36.207892339] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:11:36.209280775] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:11:50.084843297] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:11:50.087735427] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:11:50.781799457] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:11:50.782473508] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:13:26.838921929] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:13:26.839924849] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:13:27.507400491] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:13:27.519784916] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:20:50.287412054] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:20:50.288345091] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:20:50.947734684] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:20:50.948553296] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA
Configuring still capture...
Still capture setup complete
[0:21:04.852900429] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 4608x2592-BGR888
[0:21:04.853822133] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 4608x2592-SBGGR10_1X10 - Selected unicam format: 4608x2592-pBAA
Configuring still capture...
Still capture setup complete
[0:21:05.520749061] [649]  INFO Camera camera.cpp:1026 configuring streams: (0) 1920x1280-BGR888
[0:21:05.531682362] [639]  INFO RPI raspberrypi.cpp:805 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA

Additional information about your setup (OctoPrint version, OctoPi version, ...)
OctoPrint v1.8.6
Raspberry Pi 4B

connectivity.connection_check: 1.1.1.1:53
connectivity.connection_ok: true
connectivity.enabled: true
connectivity.online: true
connectivity.resolution_check: octoprint.org
connectivity.resolution_ok: true
env.hardware.cores: 4
env.hardware.freq: 1500
env.hardware.ram: 3926347776
env.os.bits: 64
env.os.id: linux
env.os.platform: linux
env.plugins.pi_support.model: Raspberry Pi 4 Model B Rev 1.2
env.plugins.pi_support.octopi_version: 1.0.0
env.plugins.pi_support.throttle_check_enabled: true
env.plugins.pi_support.throttle_check_functional: true
env.plugins.pi_support.throttle_state: 0x0
env.python.pip: 22.3
env.python.version: 3.9.2
env.python.virtualenv: true
octoprint.last_safe_mode.date: unknown
octoprint.last_safe_mode.reason: unknown
octoprint.safe_mode: false
octoprint.version: 1.8.6
printer.firmware: 2.0.8.2 (Jul 6 2022 19:18:56)
systeminfo.generated: 2023-01-21T03:38:22Z
systeminfo.generator: systemapi

Hello @tng-ryan !

What plugins do you have running?

You are running your camera at full HD/30fps. This can easily consume a ton of bandwidth. Mjpg format streaming is not compressed and is the equivalent of sending a full jpg image for every frame. 1920x1080 @ 30fps could be 100mb/s.

Test it in safe mode & then test the difference between streaming the camera & not streaming the camera. Some plugins could cause the stream to be consumed all the time.

2 Likes

Thank you, this is good info... is there a way to optimize this at all? I have another computer that I'm streaming the octoprint video from, and then encoding it with a few other video sources to stream, but the bandwidth being taken up just by this single webcam stream is causing the whole thing to be choppy.

I didn't know if there was a good way to export a list of plugins, so I just did a screenshot. I definitely need to clean these up though as they are not all being used actively.

My first recommendation is to reduce the framerate or resolution. You can easily halve if not more and still have an acceptable stream to watch your printer. 720p15 would use 1/4 of the bandwidth. Play with the parameters a bit.

You could try using HLS streaming on OctoPi (see the switch in octopi.txt, and swap your stream URL). Or setup webrtc/h264 streaming - there's a post on these forums about that. OctoPrint 1.9.0 will be shipping with a new webcam plugin system to make swapping streaming formats easier.